@purescraps/purehtml 0.7.1 → 0.8.0
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/examples/simple.js +39 -3
- package/dist/examples/simple.js.map +1 -1
- package/dist/src/index.js +39 -3
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
package/dist/examples/simple.js
CHANGED
|
@@ -6757,6 +6757,35 @@ var NumberTransformer = class extends Transformer {
|
|
|
6757
6757
|
}
|
|
6758
6758
|
};
|
|
6759
6759
|
|
|
6760
|
+
// src/transformers/remove-last-path-section.ts
|
|
6761
|
+
var RemoveLastPathSection = class _RemoveLastPathSection extends Transformer {
|
|
6762
|
+
static transformerName = "removeLastPathSection";
|
|
6763
|
+
static getName() {
|
|
6764
|
+
return _RemoveLastPathSection.transformerName;
|
|
6765
|
+
}
|
|
6766
|
+
inputType() {
|
|
6767
|
+
return STRING;
|
|
6768
|
+
}
|
|
6769
|
+
outputType() {
|
|
6770
|
+
return STRING;
|
|
6771
|
+
}
|
|
6772
|
+
transform({ val }) {
|
|
6773
|
+
if (val === null) return null;
|
|
6774
|
+
if (typeof val !== "string") {
|
|
6775
|
+
throw new Error(
|
|
6776
|
+
`${_RemoveLastPathSection.transformerName}: expects string. Got ${JSON.stringify(
|
|
6777
|
+
val
|
|
6778
|
+
)}`
|
|
6779
|
+
);
|
|
6780
|
+
}
|
|
6781
|
+
const url = new URL(val);
|
|
6782
|
+
const sections = url.pathname.split("/");
|
|
6783
|
+
sections.pop();
|
|
6784
|
+
url.pathname = sections.join("/");
|
|
6785
|
+
return url.toString();
|
|
6786
|
+
}
|
|
6787
|
+
};
|
|
6788
|
+
|
|
6760
6789
|
// src/transformers/remove-url-query-param.ts
|
|
6761
6790
|
var RemoveUrlQueryParam = class _RemoveUrlQueryParam extends Transformer {
|
|
6762
6791
|
constructor(args) {
|
|
@@ -6784,10 +6813,16 @@ var RemoveUrlQueryParam = class _RemoveUrlQueryParam extends Transformer {
|
|
|
6784
6813
|
)}`
|
|
6785
6814
|
);
|
|
6786
6815
|
}
|
|
6787
|
-
if (args.length === 0) return val;
|
|
6788
6816
|
const url = new URL(val);
|
|
6789
|
-
|
|
6790
|
-
url.searchParams.
|
|
6817
|
+
if (args.length === 0) {
|
|
6818
|
+
const keys = Array.from(url.searchParams.keys());
|
|
6819
|
+
keys.forEach((key) => {
|
|
6820
|
+
url.searchParams.delete(key);
|
|
6821
|
+
});
|
|
6822
|
+
} else {
|
|
6823
|
+
for (const paramName of args) {
|
|
6824
|
+
url.searchParams.delete(paramName);
|
|
6825
|
+
}
|
|
6791
6826
|
}
|
|
6792
6827
|
return url.toString();
|
|
6793
6828
|
}
|
|
@@ -6892,6 +6927,7 @@ var Transformers = class _Transformers {
|
|
|
6892
6927
|
JSONTransformer,
|
|
6893
6928
|
Length,
|
|
6894
6929
|
NumberTransformer,
|
|
6930
|
+
RemoveLastPathSection,
|
|
6895
6931
|
RemoveUrlQueryParam,
|
|
6896
6932
|
ResolveTransformer,
|
|
6897
6933
|
Trim,
|