@adviser/cement 0.2.30 → 0.2.31
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/index.cjs +27 -11
- package/index.cjs.map +1 -1
- package/index.d.cts +17 -2
- package/index.d.ts +17 -2
- package/index.js +31 -15
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/jsr.json +1 -1
- package/src/uri.ts +43 -9
- package/src/utils/stripper.ts +59 -0
- package/ts/uri.d.ts +16 -1
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +21 -9
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +28 -0
- package/ts/uri.test.js.map +1 -1
- package/ts/utils/stripper.d.ts +3 -0
- package/ts/utils/stripper.d.ts.map +1 -0
- package/ts/utils/stripper.js +56 -0
- package/ts/utils/stripper.js.map +1 -0
- package/ts/utils/stripper.test.d.ts +2 -0
- package/ts/utils/stripper.test.d.ts.map +1 -0
- package/ts/utils/stripper.test.js +97 -0
- package/ts/utils/stripper.test.js.map +1 -0
package/index.cjs
CHANGED
|
@@ -140,9 +140,9 @@ __export(src_exports, {
|
|
|
140
140
|
bin2text: () => bin2text,
|
|
141
141
|
envFactory: () => envFactory,
|
|
142
142
|
exception2Result: () => exception2Result,
|
|
143
|
+
hasHostPartProtocols: () => hasHostPartProtocols,
|
|
143
144
|
isURL: () => isURL,
|
|
144
145
|
logValue: () => logValue,
|
|
145
|
-
protocols: () => protocols,
|
|
146
146
|
removeSelfRef: () => removeSelfRef,
|
|
147
147
|
runtimeFn: () => runtimeFn,
|
|
148
148
|
toCryptoRuntime: () => toCryptoRuntime,
|
|
@@ -1077,7 +1077,7 @@ var MutableURL = class _MutableURL extends URL {
|
|
|
1077
1077
|
constructor(urlStr) {
|
|
1078
1078
|
super("defect://does.not.exist");
|
|
1079
1079
|
const partedURL = urlStr.split(":");
|
|
1080
|
-
this._hasHostpart =
|
|
1080
|
+
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
|
1081
1081
|
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
|
1082
1082
|
if (!this._hasHostpart) {
|
|
1083
1083
|
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
|
@@ -1104,32 +1104,32 @@ var MutableURL = class _MutableURL extends URL {
|
|
|
1104
1104
|
get host() {
|
|
1105
1105
|
if (!this._hasHostpart) {
|
|
1106
1106
|
throw new Error(
|
|
1107
|
-
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(
|
|
1107
|
+
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
|
1108
1108
|
);
|
|
1109
1109
|
}
|
|
1110
1110
|
return this._sysURL.host;
|
|
1111
1111
|
}
|
|
1112
1112
|
get port() {
|
|
1113
1113
|
if (!this._hasHostpart) {
|
|
1114
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
|
1114
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
|
1115
1115
|
}
|
|
1116
1116
|
return this._sysURL.port;
|
|
1117
1117
|
}
|
|
1118
1118
|
set port(p) {
|
|
1119
1119
|
if (!this._hasHostpart) {
|
|
1120
|
-
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(
|
|
1120
|
+
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
|
1121
1121
|
}
|
|
1122
1122
|
this._sysURL.port = p;
|
|
1123
1123
|
}
|
|
1124
1124
|
get hostname() {
|
|
1125
1125
|
if (!this._hasHostpart) {
|
|
1126
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
|
1126
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
|
1127
1127
|
}
|
|
1128
1128
|
return this._sysURL.hostname;
|
|
1129
1129
|
}
|
|
1130
1130
|
set hostname(h) {
|
|
1131
1131
|
if (!this._hasHostpart) {
|
|
1132
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
|
1132
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
|
1133
1133
|
}
|
|
1134
1134
|
this._sysURL.hostname = h;
|
|
1135
1135
|
}
|
|
@@ -1272,13 +1272,13 @@ var BuildURI = class _BuildURI {
|
|
|
1272
1272
|
return URI.from(this._url);
|
|
1273
1273
|
}
|
|
1274
1274
|
};
|
|
1275
|
-
var
|
|
1275
|
+
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
|
1276
1276
|
var URI = class _URI {
|
|
1277
1277
|
static protocolHasHostpart(protocol) {
|
|
1278
1278
|
protocol = protocol.replace(/:$/, "");
|
|
1279
|
-
|
|
1279
|
+
hasHostPartProtocols.add(protocol);
|
|
1280
1280
|
return () => {
|
|
1281
|
-
|
|
1281
|
+
hasHostPartProtocols.delete(protocol);
|
|
1282
1282
|
};
|
|
1283
1283
|
}
|
|
1284
1284
|
// if no protocol is provided, default to file:
|
|
@@ -1362,6 +1362,22 @@ var URI = class _URI {
|
|
|
1362
1362
|
toJSON() {
|
|
1363
1363
|
return this.toString();
|
|
1364
1364
|
}
|
|
1365
|
+
asObj() {
|
|
1366
|
+
const pathURI = {
|
|
1367
|
+
style: "path",
|
|
1368
|
+
protocol: this.protocol,
|
|
1369
|
+
pathname: this.pathname,
|
|
1370
|
+
searchParams: Object.fromEntries(this.getParams)
|
|
1371
|
+
};
|
|
1372
|
+
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
|
1373
|
+
return __spreadProps(__spreadValues({}, pathURI), {
|
|
1374
|
+
style: "host",
|
|
1375
|
+
hostname: this.hostname,
|
|
1376
|
+
port: this.port
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
return pathURI;
|
|
1380
|
+
}
|
|
1365
1381
|
};
|
|
1366
1382
|
|
|
1367
1383
|
// src/runtime.ts
|
|
@@ -2603,9 +2619,9 @@ function uint8array2stream(str) {
|
|
|
2603
2619
|
bin2text,
|
|
2604
2620
|
envFactory,
|
|
2605
2621
|
exception2Result,
|
|
2622
|
+
hasHostPartProtocols,
|
|
2606
2623
|
isURL,
|
|
2607
2624
|
logValue,
|
|
2608
|
-
protocols,
|
|
2609
2625
|
removeSelfRef,
|
|
2610
2626
|
runtimeFn,
|
|
2611
2627
|
toCryptoRuntime,
|