@nordcraft/std-lib 1.0.57 → 1.0.59
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.
|
@@ -5,7 +5,9 @@ import type { FormulaHandler } from '@nordcraft/core/dist/types';
|
|
|
5
5
|
*/
|
|
6
6
|
declare const handler: FormulaHandler<{
|
|
7
7
|
hostname: string;
|
|
8
|
-
searchParams:
|
|
8
|
+
searchParams: {
|
|
9
|
+
[k: string]: string;
|
|
10
|
+
};
|
|
9
11
|
path: string[];
|
|
10
12
|
hash: string;
|
|
11
13
|
href: string;
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a simplified URL object similar to the native URL
|
|
3
|
+
* while retaining the original URL object's toString method.
|
|
4
|
+
*/
|
|
5
|
+
class NCURL {
|
|
6
|
+
hostname;
|
|
7
|
+
searchParams;
|
|
8
|
+
path;
|
|
9
|
+
hash;
|
|
10
|
+
href;
|
|
11
|
+
protocol;
|
|
12
|
+
port;
|
|
13
|
+
origin;
|
|
14
|
+
constructor(url) {
|
|
15
|
+
this.hostname = url.hostname;
|
|
16
|
+
this.searchParams = Object.fromEntries(url.searchParams);
|
|
17
|
+
this.path = url.pathname.split('/').filter((p, i) => i !== 0 || p !== '');
|
|
18
|
+
this.hash = url.hash.replace('#', '');
|
|
19
|
+
this.href = url.href;
|
|
20
|
+
this.protocol = url.protocol;
|
|
21
|
+
this.port = url.port;
|
|
22
|
+
this.origin = url.origin;
|
|
23
|
+
}
|
|
24
|
+
toString() {
|
|
25
|
+
// This is the same functionality as URL.prototype.toString (https://developer.mozilla.org/en-US/docs/Web/API/URL#instance_methods)
|
|
26
|
+
return this.href;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
1
29
|
/**
|
|
2
30
|
* Similar to https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
|
|
3
31
|
* but returns searchParams as an object and path as an array without leading empty string
|
|
@@ -7,19 +35,7 @@ const handler = ([url, base]) => {
|
|
|
7
35
|
return null;
|
|
8
36
|
}
|
|
9
37
|
try {
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
hostname,
|
|
13
|
-
searchParams: Object.fromEntries(searchParams),
|
|
14
|
-
// Remove the first "empty" path parameter and return path parameters as an array
|
|
15
|
-
path: pathname.split('/').filter((p, i) => i !== 0 || p !== ''),
|
|
16
|
-
// Remove the leading '#' (havelåge)
|
|
17
|
-
hash: hash.replace('#', ''),
|
|
18
|
-
href,
|
|
19
|
-
protocol,
|
|
20
|
-
port,
|
|
21
|
-
origin,
|
|
22
|
-
};
|
|
38
|
+
return new NCURL(new URL(url, typeof base === 'string' ? base : undefined));
|
|
23
39
|
}
|
|
24
40
|
catch {
|
|
25
41
|
// Invalid url
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/parseURL/handler.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/parseURL/handler.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,KAAK;IACT,QAAQ,CAAQ;IAChB,YAAY,CAEX;IACD,IAAI,CAAU;IACd,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,QAAQ,CAAQ;IAChB,IAAI,CAAQ;IACZ,MAAM,CAAQ;IAEd,YAAY,GAAQ;QAClB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACxD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACzE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QACrC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED,QAAQ;QACN,mIAAmI;QACnI,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,GAWR,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACnB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;QACd,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AACD,eAAe,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
"homepage": "https://github.com/nordcraftengine/nordcraft",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"fast-deep-equal": "3.1.3",
|
|
8
|
-
"@nordcraft/core": "1.0.
|
|
8
|
+
"@nordcraft/core": "1.0.59"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/node": "24.3.1",
|
|
12
|
-
"@happy-dom/global-registrator": "
|
|
12
|
+
"@happy-dom/global-registrator": "20.0.8",
|
|
13
|
+
"happy-dom": "20.0.8",
|
|
13
14
|
"jsonschema": "1.5.0"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
@@ -19,5 +20,5 @@
|
|
|
19
20
|
"watch": "tsc --noEmit -w"
|
|
20
21
|
},
|
|
21
22
|
"files": ["dist"],
|
|
22
|
-
"version": "1.0.
|
|
23
|
+
"version": "1.0.59"
|
|
23
24
|
}
|