mirror of
https://github.com/dzeiocom/libs.git
synced 2025-07-29 08:19:51 +00:00
Merge branch 'master' into make-functions-use-null-23
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dzeio/url-manager",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "A simple to use yet complete Urls parser and serializer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -10,7 +10,8 @@
|
||||
"homepage": "https://github.com/dzeiocom/libs/tree/master/packages/url-manager#readme",
|
||||
"author": "Aviortheking",
|
||||
"license": "MIT",
|
||||
"main": "./dist/URLManager.js",
|
||||
"main": "./dist/cjs/URLManager.js",
|
||||
"module": "./dist/esm/URLManager.js",
|
||||
"types": "./dist/URLManager.d.ts",
|
||||
"keywords": [
|
||||
"url",
|
||||
@ -21,17 +22,14 @@
|
||||
"serializer"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.12",
|
||||
"@types/jest": "^26.0.10",
|
||||
"jest": "^26.4.2",
|
||||
"parcel": "^1.12.4",
|
||||
"ts-jest": "^26.4.4",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.0.2"
|
||||
"esbuild": "^0.13.2"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "yarn build",
|
||||
"build": "parcel build src/index.ts --out-file browser.js --experimental-scope-hoisting && tsc",
|
||||
"prepublishOnly": "npm run build",
|
||||
"build": "esbuild src/index.ts --bundle --outfile=dist/browser.js --minify --target=es6 && tsc && tsc --project tsconfig.esm.json",
|
||||
"test": "jest --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dzeio/object-util": "^1.4.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { objectLoop } from '@dzeio/object-util'
|
||||
|
||||
/**
|
||||
* Easy URLs manager
|
||||
*/
|
||||
@ -331,13 +333,9 @@ export default class URLManager {
|
||||
return undefined
|
||||
}
|
||||
if (format) {
|
||||
for (const key in format) {
|
||||
if (!(key in format)) {
|
||||
continue
|
||||
}
|
||||
const replacing = format[key]
|
||||
path = path.replace(`[${key}]`, replacing)
|
||||
}
|
||||
objectLoop(format, (replacing, key) => {
|
||||
path = path?.replace(`[${key}]`, replacing)
|
||||
})
|
||||
}
|
||||
return `${(path.startsWith('/') ? '' : '/')}${path}`
|
||||
}
|
||||
@ -345,24 +343,17 @@ export default class URLManager {
|
||||
private formatQuery(options?: { queryArrayJoin?: string }) {
|
||||
let result = ''
|
||||
const queryTmp = this.query()
|
||||
|
||||
for (const key in queryTmp) {
|
||||
if (!Object.prototype.hasOwnProperty.call(queryTmp, key)) {
|
||||
continue
|
||||
}
|
||||
|
||||
const element = queryTmp[key]
|
||||
|
||||
objectLoop(queryTmp, (element, key) => {
|
||||
result += result.length === 0 ? '?' : '&'
|
||||
|
||||
if (typeof element !== 'object') {
|
||||
result += `${key}=${element}`
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
if (options?.queryArrayJoin) {
|
||||
result += `${key}=${element.join(options.queryArrayJoin)}`
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
for (let i = 0; i < element.length; i++) {
|
||||
@ -372,7 +363,7 @@ export default class URLManager {
|
||||
}
|
||||
result += `${key}=${val}`
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!result) {
|
||||
return undefined
|
||||
|
11
packages/url-manager/tsconfig.esm.json
Normal file
11
packages/url-manager/tsconfig.esm.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "../config/tsconfig.esm.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist/esm",
|
||||
"declaration": false,
|
||||
"declarationDir": null
|
||||
},
|
||||
"files": [
|
||||
"src/URLManager.ts"
|
||||
]
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
"outDir": "dist/cjs",
|
||||
"declarationDir": "dist/types"
|
||||
},
|
||||
"files": [
|
||||
"src/URLManager.ts"
|
||||
|
Reference in New Issue
Block a user