@naverpay/nurl 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/nurl.d.ts +2 -1
- package/dist/cjs/nurl.js +1 -1
- package/dist/cjs/utils.d.ts +13 -5
- package/dist/cjs/utils.js +1 -1
- package/dist/esm/nurl.d.mts +2 -1
- package/dist/esm/nurl.mjs +5 -5
- package/dist/esm/utils.d.mts +13 -5
- package/dist/esm/utils.mjs +40 -30
- package/package.json +1 -1
package/dist/cjs/nurl.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Query } from './utils';
|
|
1
2
|
interface URLOptions extends Partial<Pick<URL, 'href' | 'protocol' | 'host' | 'hostname' | 'port' | 'pathname' | 'search' | 'hash' | 'username' | 'password'>> {
|
|
2
3
|
baseUrl?: string;
|
|
3
|
-
query?:
|
|
4
|
+
query?: Query;
|
|
4
5
|
basePath?: string;
|
|
5
6
|
}
|
|
6
7
|
export default class NURL implements URL {
|
package/dist/cjs/nurl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./punycode.js"),r=require("./utils.js");class a{constructor(t){if(this._href="",this._protocol="",this._host="",this._hostname="",this._port="",this._pathname="",this._search="",this._hash="",this._origin="",this._username="",this._password="",this._baseUrl="",this._searchParams=new URLSearchParams,this._basePath="",this.punycodePrefix="xn--",this._searchParams=new URLSearchParams,typeof t=="string"||t instanceof URL)this.href=t.toString();else if(t){if(t.basePath&&(this._basePath=t.basePath.startsWith("/")?t.basePath:`/${t.basePath}`),t.baseUrl&&(this.baseUrl=t.baseUrl),t.href&&(this.href=t.href),t.protocol&&(this.protocol=t.protocol),t.host&&(this.host=t.host),t.hostname&&(this.hostname=t.hostname),t.port&&(this.port=t.port),t.pathname){const s=this._basePath;let e=t.pathname;s&&!e.startsWith(s)&&(e=`${s}${e.startsWith("/")?"":"/"}${e}`),this.pathname=r.refinePathnameWithQuery(e,t.query??{})}if(t.search&&(this.search=t.search),t.hash&&(this.hash=t.hash),t.username&&(this.username=t.username),t.password&&(this.password=t.password),t.query){const s=r.refineQueryWithPathname(t.pathname??"",t.query);Object.keys(s).length>0&&(this.search=new URLSearchParams(s).toString())}this.updateHref()}}static withBasePath(t){return s=>typeof s=="string"||s instanceof URL?new a({href:s.toString(),basePath:t}):new a({...s,basePath:t})}static create(t){return new a(t)}static canParse(t){if(t.startsWith("/"))return/^\/[^?#]*(\?[^#]*)?(#.*)?$/.test(t);try{return new URL(t),!0}catch{return/^[^:/?#]+(\.[^:/?#]+)+(\/[^?#]*(\?[^#]*)?(#.*)?)?$/.test(t)}}get baseUrl(){return this._baseUrl}set baseUrl(t){this._baseUrl=t;try{const s=new URL(t);this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._origin=s.origin,this._username=s.username,this._password=s.password,s.pathname!=="/"&&(this._pathname=s.pathname),s.search&&(this._search=s.search,this._searchParams=new URLSearchParams(s.search)),s.hash&&(this._hash=s.hash),this.updateHref()}catch(s){console.warn(`Invalid baseUrl: ${t}`,s)}}get href(){return this.pathname.length===1?`${this._href}/`:this._href}set href(t){try{const s=new URL(t);this._href=s.href,this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._pathname=s.pathname,this._search=s.search,this._hash=s.hash,this._origin=s.origin,this._username=s.username,this._password=s.password,this._searchParams=s.searchParams}catch(s){console.warn(`Can not parse ${t}`,s)}}get protocol(){return this._protocol}set protocol(t){this._protocol=t,this.updateHref()}get host(){return this._host}set host(t){const[s,e]=t.split(":"),h=this.encodeHostname(s);this._host=e?`${h}:${e}`:h,this._hostname=h,this._port=e||"",this.updateHref()}get hostname(){return this._hostname}set hostname(t){const s=this.encodeHostname(t);this._hostname=s,this._host=this._port?`${s}:${this._port}`:s,this.updateHref()}get port(){return this._port}set port(t){this._port=t,this._host=`${this._hostname}${t?":"+t:""}`,this.updateHref()}get pathname(){return this._pathname}set pathname(t){let s=t;this._basePath&&!s.startsWith(this._basePath)&&(s=`${this._basePath}${s.startsWith("/")?"":"/"}${s}`);const e=s.split("/").map(h=>r.isDynamicPath(h)?h:encodeURI(h)).join("/");this._pathname=e.startsWith("/")?e:`/${e}`,this.updateHref()}get search(){return this._search}set search(t){this._search=t.startsWith("?")?t:`?${t}`,this._searchParams=new URLSearchParams(t),this.updateHref()}setSearchParams(t){const s=new URLSearchParams(t);this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}appendSearchParams(t){const s=new URLSearchParams(this._searchParams),e=r.getDynamicPaths(this._pathname).map(r.extractPathKey);Object.keys(t).forEach(h=>{e.includes(h)?this._pathname=r.refinePathnameWithQuery(this._pathname,{[h]:t[h]}):s.append(h,t[h])}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}removeSearchParams(...t){const s=new URLSearchParams(this._searchParams);t.forEach(e=>{s.delete(e)}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}get searchParams(){return new Proxy(this._searchParams,{get:(t,s,e)=>{const h=Reflect.get(t,s,e);return typeof h=="function"?(...o)=>{const n=h.apply(t,o);return this._search=this._searchParams.toString()?`?${this._searchParams.toString()}`:"",this.updateHref(),n}:h}})}get hash(){return this._hash}set hash(t){this._hash=t.startsWith("#")?t:`#${t}`,this.updateHref()}get origin(){return this._origin}get username(){return this._username}set username(t){this._username=t,this.updateHref()}get password(){return this._password}set password(t){this._password=t,this.updateHref()}updateHref(){if(this._baseUrl){const t=new URL(this._baseUrl);t.pathname=this._pathname,t.search=this._search,t.hash=this._hash,this._href=t.href,this._origin=t.origin}else this._href=`${this._protocol}${this._protocol&&"//"}${this._username}${this._password?":"+this._password:""}${this._username||this._password?"@":""}${this._hostname}${this._port?":"+this._port:""}${this._pathname==="/"?"":this._pathname}${this._search}${this._hash}`,this._origin=`${this._protocol}//${this._hostname}${this._port?":"+this._port:""}`}toString(){return this.href}toJSON(){return this.href}encodeHostname(t){return t.split(".").map(s=>{for(const e of s)if(r.isASCIICodeChar(e))return`${this.punycodePrefix}${i.encode(s)}`;return s}).join(".")}get decodedIDN(){let t=this._href;return this._hostname.split(".").forEach(s=>{t=t.replace(s,i.decode(s.replace(this.punycodePrefix,"")))}),t}get decodedHostname(){return this._hostname.split(".").map(t=>i.decode(t.replace(this.punycodePrefix,""))).join(".")}}module.exports=a;
|
|
1
|
+
"use strict";const i=require("./punycode.js"),r=require("./utils.js");class a{constructor(t){if(this._href="",this._protocol="",this._host="",this._hostname="",this._port="",this._pathname="",this._search="",this._hash="",this._origin="",this._username="",this._password="",this._baseUrl="",this._searchParams=new URLSearchParams,this._basePath="",this.punycodePrefix="xn--",this._searchParams=new URLSearchParams,typeof t=="string"||t instanceof URL)this.href=t.toString();else if(t){if(t.basePath&&(this._basePath=t.basePath.startsWith("/")?t.basePath:`/${t.basePath}`),t.baseUrl&&(this.baseUrl=t.baseUrl),t.href&&(this.href=t.href),t.protocol&&(this.protocol=t.protocol),t.host&&(this.host=t.host),t.hostname&&(this.hostname=t.hostname),t.port&&(this.port=t.port),t.pathname){const s=this._basePath;let e=t.pathname;s&&!e.startsWith(s)&&(e=`${s}${e.startsWith("/")?"":"/"}${e}`),this.pathname=r.refinePathnameWithQuery(e,t.query??{})}if(t.search&&(this.search=t.search),t.hash&&(this.hash=t.hash),t.username&&(this.username=t.username),t.password&&(this.password=t.password),t.query){const s=r.refineQueryWithPathname(t.pathname??"",t.query);Object.keys(s).length>0&&(this.search=new URLSearchParams(r.convertQueryToArray(s)).toString())}this.updateHref()}}static withBasePath(t){return s=>typeof s=="string"||s instanceof URL?new a({href:s.toString(),basePath:t}):new a({...s,basePath:t})}static create(t){return new a(t)}static canParse(t){if(t.startsWith("/"))return/^\/[^?#]*(\?[^#]*)?(#.*)?$/.test(t);try{return new URL(t),!0}catch{return/^[^:/?#]+(\.[^:/?#]+)+(\/[^?#]*(\?[^#]*)?(#.*)?)?$/.test(t)}}get baseUrl(){return this._baseUrl}set baseUrl(t){this._baseUrl=t;try{const s=new URL(t);this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._origin=s.origin,this._username=s.username,this._password=s.password,s.pathname!=="/"&&(this._pathname=s.pathname),s.search&&(this._search=s.search,this._searchParams=new URLSearchParams(s.search)),s.hash&&(this._hash=s.hash),this.updateHref()}catch(s){console.warn(`Invalid baseUrl: ${t}`,s)}}get href(){return this.pathname.length===1?`${this._href}/`:this._href}set href(t){try{const s=new URL(t);this._href=s.href,this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._pathname=s.pathname,this._search=s.search,this._hash=s.hash,this._origin=s.origin,this._username=s.username,this._password=s.password,this._searchParams=s.searchParams}catch(s){console.warn(`Can not parse ${t}`,s)}}get protocol(){return this._protocol}set protocol(t){this._protocol=t,this.updateHref()}get host(){return this._host}set host(t){const[s,e]=t.split(":"),h=this.encodeHostname(s);this._host=e?`${h}:${e}`:h,this._hostname=h,this._port=e||"",this.updateHref()}get hostname(){return this._hostname}set hostname(t){const s=this.encodeHostname(t);this._hostname=s,this._host=this._port?`${s}:${this._port}`:s,this.updateHref()}get port(){return this._port}set port(t){this._port=t,this._host=`${this._hostname}${t?":"+t:""}`,this.updateHref()}get pathname(){return this._pathname}set pathname(t){let s=t;this._basePath&&!s.startsWith(this._basePath)&&(s=`${this._basePath}${s.startsWith("/")?"":"/"}${s}`);const e=s.split("/").map(h=>r.isDynamicPath(h)?h:encodeURI(h)).join("/");this._pathname=e.startsWith("/")?e:`/${e}`,this.updateHref()}get search(){return this._search}set search(t){this._search=t.startsWith("?")?t:`?${t}`,this._searchParams=new URLSearchParams(t),this.updateHref()}setSearchParams(t){const s=new URLSearchParams(t);this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}appendSearchParams(t){const s=new URLSearchParams(this._searchParams),e=r.getDynamicPaths(this._pathname).map(r.extractPathKey);Object.keys(t).forEach(h=>{e.includes(h)?this._pathname=r.refinePathnameWithQuery(this._pathname,{[h]:t[h]}):s.append(h,t[h])}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}removeSearchParams(...t){const s=new URLSearchParams(this._searchParams);t.forEach(e=>{s.delete(e)}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}get searchParams(){return new Proxy(this._searchParams,{get:(t,s,e)=>{const h=Reflect.get(t,s,e);return typeof h=="function"?(...o)=>{const n=h.apply(t,o);return this._search=this._searchParams.toString()?`?${this._searchParams.toString()}`:"",this.updateHref(),n}:h}})}get hash(){return this._hash}set hash(t){this._hash=t.startsWith("#")?t:`#${t}`,this.updateHref()}get origin(){return this._origin}get username(){return this._username}set username(t){this._username=t,this.updateHref()}get password(){return this._password}set password(t){this._password=t,this.updateHref()}updateHref(){if(this._baseUrl){const t=new URL(this._baseUrl);t.pathname=this._pathname,t.search=this._search,t.hash=this._hash,this._href=t.href,this._origin=t.origin}else this._href=`${this._protocol}${this._protocol&&"//"}${this._username}${this._password?":"+this._password:""}${this._username||this._password?"@":""}${this._hostname}${this._port?":"+this._port:""}${this._pathname==="/"?"":this._pathname}${this._search}${this._hash}`,this._origin=`${this._protocol}//${this._hostname}${this._port?":"+this._port:""}`}toString(){return this.href}toJSON(){return this.href}encodeHostname(t){return t.split(".").map(s=>{for(const e of s)if(r.isASCIICodeChar(e))return`${this.punycodePrefix}${i.encode(s)}`;return s}).join(".")}get decodedIDN(){let t=this._href;return this._hostname.split(".").forEach(s=>{t=t.replace(s,i.decode(s.replace(this.punycodePrefix,"")))}),t}get decodedHostname(){return this._hostname.split(".").map(t=>i.decode(t.replace(this.punycodePrefix,""))).join(".")}}module.exports=a;
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
export type Query = Record<string, string | number | boolean | (string | number | boolean)[]>;
|
|
1
2
|
export declare function isDynamicPath(path: string): boolean;
|
|
2
3
|
export declare function getDynamicPaths(pathname: string): string[];
|
|
3
4
|
export declare function extractPathKey(path: string): string;
|
|
4
5
|
/**
|
|
5
6
|
* Replaces dynamic paths in the pathname with values from the query
|
|
6
7
|
* @param {string} pathname
|
|
7
|
-
* @param {
|
|
8
|
+
* @param {Query} query
|
|
8
9
|
* @returns {string} refined pathname
|
|
9
10
|
*/
|
|
10
|
-
export declare function refinePathnameWithQuery(pathname: string, query:
|
|
11
|
+
export declare function refinePathnameWithQuery(pathname: string, query: Query): string;
|
|
11
12
|
/**
|
|
12
13
|
* Removes queries that have already been used in the pathname.
|
|
13
14
|
* @param {string} pathname
|
|
14
|
-
* @param {
|
|
15
|
-
* @returns {
|
|
15
|
+
* @param {Query} query
|
|
16
|
+
* @returns {Query} refined query
|
|
16
17
|
*/
|
|
17
|
-
export declare function refineQueryWithPathname(pathname: string, query:
|
|
18
|
+
export declare function refineQueryWithPathname(pathname: string, query: Query): Query;
|
|
18
19
|
export declare function isASCIICodeChar(char: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Convert queries to array, if they are not of the defined primitive types, they will not be included in the array.
|
|
22
|
+
* @param {string} pathname
|
|
23
|
+
* @param {Query} query
|
|
24
|
+
* @returns {string[][]} refined query
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertQueryToArray(query: Query): string[][];
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=/^:/,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=/^:/,P=/^\[.*\]$/;function y(e){return c.test(e)||P.test(e)}function o(e){return e.split("/").filter(y)}function a(e){return e.slice(1,c.test(e)?void 0:-1)}function h(e,r){return o(e).reduce((t,n)=>{const i=a(n),u=r[i];return u&&typeof u=="string"?t.replace(n,u):t},e)}function A(e,r){return o(e).reduce((t,n)=>{const i=a(n);if(typeof t[i]!="string")return t;const{[i]:g,...f}=t;return f},r)}const C=127;function m(e){return e.charCodeAt(0)>C}function s(e){return["string","number","boolean"].includes(typeof e)}function d(e){return Object.entries(e).flatMap(([r,t])=>s(t)?[[r,String(t)]]:Array.isArray(t)&&t.every(s)?t.map(n=>[r,String(n)]):[])}exports.convertQueryToArray=d;exports.extractPathKey=a;exports.getDynamicPaths=o;exports.isASCIICodeChar=m;exports.isDynamicPath=y;exports.refinePathnameWithQuery=h;exports.refineQueryWithPathname=A;
|
package/dist/esm/nurl.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Query } from './utils';
|
|
1
2
|
interface URLOptions extends Partial<Pick<URL, 'href' | 'protocol' | 'host' | 'hostname' | 'port' | 'pathname' | 'search' | 'hash' | 'username' | 'password'>> {
|
|
2
3
|
baseUrl?: string;
|
|
3
|
-
query?:
|
|
4
|
+
query?: Query;
|
|
4
5
|
basePath?: string;
|
|
5
6
|
}
|
|
6
7
|
export default class NURL implements URL {
|
package/dist/esm/nurl.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encode as c, decode as a } from "./punycode.mjs";
|
|
2
|
-
import { refinePathnameWithQuery as i, refineQueryWithPathname as _,
|
|
2
|
+
import { refinePathnameWithQuery as i, refineQueryWithPathname as _, convertQueryToArray as m, isDynamicPath as f, getDynamicPaths as p, extractPathKey as d, isASCIICodeChar as P } from "./utils.mjs";
|
|
3
3
|
class r {
|
|
4
4
|
constructor(t) {
|
|
5
5
|
if (this._href = "", this._protocol = "", this._host = "", this._hostname = "", this._port = "", this._pathname = "", this._search = "", this._hash = "", this._origin = "", this._username = "", this._password = "", this._baseUrl = "", this._searchParams = new URLSearchParams(), this._basePath = "", this.punycodePrefix = "xn--", this._searchParams = new URLSearchParams(), typeof t == "string" || t instanceof URL)
|
|
@@ -12,7 +12,7 @@ class r {
|
|
|
12
12
|
}
|
|
13
13
|
if (t.search && (this.search = t.search), t.hash && (this.hash = t.hash), t.username && (this.username = t.username), t.password && (this.password = t.password), t.query) {
|
|
14
14
|
const s = _(t.pathname ?? "", t.query);
|
|
15
|
-
Object.keys(s).length > 0 && (this.search = new URLSearchParams(s).toString());
|
|
15
|
+
Object.keys(s).length > 0 && (this.search = new URLSearchParams(m(s)).toString());
|
|
16
16
|
}
|
|
17
17
|
this.updateHref();
|
|
18
18
|
}
|
|
@@ -93,7 +93,7 @@ class r {
|
|
|
93
93
|
set pathname(t) {
|
|
94
94
|
let s = t;
|
|
95
95
|
this._basePath && !s.startsWith(this._basePath) && (s = `${this._basePath}${s.startsWith("/") ? "" : "/"}${s}`);
|
|
96
|
-
const e = s.split("/").map((h) =>
|
|
96
|
+
const e = s.split("/").map((h) => f(h) ? h : encodeURI(h)).join("/");
|
|
97
97
|
this._pathname = e.startsWith("/") ? e : `/${e}`, this.updateHref();
|
|
98
98
|
}
|
|
99
99
|
get search() {
|
|
@@ -107,7 +107,7 @@ class r {
|
|
|
107
107
|
this._search = s.toString() ? `?${s.toString()}` : "", this._searchParams = s, this.updateHref();
|
|
108
108
|
}
|
|
109
109
|
appendSearchParams(t) {
|
|
110
|
-
const s = new URLSearchParams(this._searchParams), e =
|
|
110
|
+
const s = new URLSearchParams(this._searchParams), e = p(this._pathname).map(d);
|
|
111
111
|
Object.keys(t).forEach((h) => {
|
|
112
112
|
e.includes(h) ? this._pathname = i(this._pathname, {
|
|
113
113
|
[h]: t[h]
|
|
@@ -168,7 +168,7 @@ class r {
|
|
|
168
168
|
encodeHostname(t) {
|
|
169
169
|
return t.split(".").map((s) => {
|
|
170
170
|
for (const e of s)
|
|
171
|
-
if (
|
|
171
|
+
if (P(e))
|
|
172
172
|
return `${this.punycodePrefix}${c(s)}`;
|
|
173
173
|
return s;
|
|
174
174
|
}).join(".");
|
package/dist/esm/utils.d.mts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
export type Query = Record<string, string | number | boolean | (string | number | boolean)[]>;
|
|
1
2
|
export declare function isDynamicPath(path: string): boolean;
|
|
2
3
|
export declare function getDynamicPaths(pathname: string): string[];
|
|
3
4
|
export declare function extractPathKey(path: string): string;
|
|
4
5
|
/**
|
|
5
6
|
* Replaces dynamic paths in the pathname with values from the query
|
|
6
7
|
* @param {string} pathname
|
|
7
|
-
* @param {
|
|
8
|
+
* @param {Query} query
|
|
8
9
|
* @returns {string} refined pathname
|
|
9
10
|
*/
|
|
10
|
-
export declare function refinePathnameWithQuery(pathname: string, query:
|
|
11
|
+
export declare function refinePathnameWithQuery(pathname: string, query: Query): string;
|
|
11
12
|
/**
|
|
12
13
|
* Removes queries that have already been used in the pathname.
|
|
13
14
|
* @param {string} pathname
|
|
14
|
-
* @param {
|
|
15
|
-
* @returns {
|
|
15
|
+
* @param {Query} query
|
|
16
|
+
* @returns {Query} refined query
|
|
16
17
|
*/
|
|
17
|
-
export declare function refineQueryWithPathname(pathname: string, query:
|
|
18
|
+
export declare function refineQueryWithPathname(pathname: string, query: Query): Query;
|
|
18
19
|
export declare function isASCIICodeChar(char: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Convert queries to array, if they are not of the defined primitive types, they will not be included in the array.
|
|
22
|
+
* @param {string} pathname
|
|
23
|
+
* @param {Query} query
|
|
24
|
+
* @returns {string[][]} refined query
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertQueryToArray(query: Query): string[][];
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -1,37 +1,47 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
return
|
|
4
|
-
}
|
|
5
|
-
function c(
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
function
|
|
12
|
-
return c(
|
|
13
|
-
const i =
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
function
|
|
18
|
-
return c(
|
|
19
|
-
const i =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
const s = /^:/, a = /^\[.*\]$/;
|
|
2
|
+
function A(r) {
|
|
3
|
+
return s.test(r) || a.test(r);
|
|
4
|
+
}
|
|
5
|
+
function c(r) {
|
|
6
|
+
return r.split("/").filter(A);
|
|
7
|
+
}
|
|
8
|
+
function f(r) {
|
|
9
|
+
return r.slice(1, s.test(r) ? void 0 : -1);
|
|
10
|
+
}
|
|
11
|
+
function _(r, e) {
|
|
12
|
+
return c(r).reduce((t, n) => {
|
|
13
|
+
const i = f(n), u = e[i];
|
|
14
|
+
return u && typeof u == "string" ? t.replace(n, u) : t;
|
|
15
|
+
}, r);
|
|
16
|
+
}
|
|
17
|
+
function d(r, e) {
|
|
18
|
+
return c(r).reduce((t, n) => {
|
|
19
|
+
const i = f(n);
|
|
20
|
+
if (typeof t[i] != "string")
|
|
21
|
+
return t;
|
|
22
|
+
const {
|
|
23
|
+
[i]: P,
|
|
24
|
+
...y
|
|
25
|
+
} = t;
|
|
26
|
+
return y;
|
|
24
27
|
}, e);
|
|
25
28
|
}
|
|
26
29
|
const C = 127;
|
|
27
|
-
function
|
|
28
|
-
return
|
|
30
|
+
function g(r) {
|
|
31
|
+
return r.charCodeAt(0) > C;
|
|
32
|
+
}
|
|
33
|
+
function o(r) {
|
|
34
|
+
return ["string", "number", "boolean"].includes(typeof r);
|
|
35
|
+
}
|
|
36
|
+
function h(r) {
|
|
37
|
+
return Object.entries(r).flatMap(([e, t]) => o(t) ? [[e, String(t)]] : Array.isArray(t) && t.every(o) ? t.map((n) => [e, String(n)]) : []);
|
|
29
38
|
}
|
|
30
39
|
export {
|
|
31
|
-
|
|
40
|
+
h as convertQueryToArray,
|
|
41
|
+
f as extractPathKey,
|
|
32
42
|
c as getDynamicPaths,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
g as isASCIICodeChar,
|
|
44
|
+
A as isDynamicPath,
|
|
45
|
+
_ as refinePathnameWithQuery,
|
|
46
|
+
d as refineQueryWithPathname
|
|
37
47
|
};
|