@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/src/index.js
CHANGED
|
@@ -6768,6 +6768,35 @@ var NumberTransformer = class extends Transformer {
|
|
|
6768
6768
|
}
|
|
6769
6769
|
};
|
|
6770
6770
|
|
|
6771
|
+
// src/transformers/remove-last-path-section.ts
|
|
6772
|
+
var RemoveLastPathSection = class _RemoveLastPathSection extends Transformer {
|
|
6773
|
+
static transformerName = "removeLastPathSection";
|
|
6774
|
+
static getName() {
|
|
6775
|
+
return _RemoveLastPathSection.transformerName;
|
|
6776
|
+
}
|
|
6777
|
+
inputType() {
|
|
6778
|
+
return STRING;
|
|
6779
|
+
}
|
|
6780
|
+
outputType() {
|
|
6781
|
+
return STRING;
|
|
6782
|
+
}
|
|
6783
|
+
transform({ val }) {
|
|
6784
|
+
if (val === null) return null;
|
|
6785
|
+
if (typeof val !== "string") {
|
|
6786
|
+
throw new Error(
|
|
6787
|
+
`${_RemoveLastPathSection.transformerName}: expects string. Got ${JSON.stringify(
|
|
6788
|
+
val
|
|
6789
|
+
)}`
|
|
6790
|
+
);
|
|
6791
|
+
}
|
|
6792
|
+
const url = new URL(val);
|
|
6793
|
+
const sections = url.pathname.split("/");
|
|
6794
|
+
sections.pop();
|
|
6795
|
+
url.pathname = sections.join("/");
|
|
6796
|
+
return url.toString();
|
|
6797
|
+
}
|
|
6798
|
+
};
|
|
6799
|
+
|
|
6771
6800
|
// src/transformers/remove-url-query-param.ts
|
|
6772
6801
|
var RemoveUrlQueryParam = class _RemoveUrlQueryParam extends Transformer {
|
|
6773
6802
|
constructor(args) {
|
|
@@ -6795,10 +6824,16 @@ var RemoveUrlQueryParam = class _RemoveUrlQueryParam extends Transformer {
|
|
|
6795
6824
|
)}`
|
|
6796
6825
|
);
|
|
6797
6826
|
}
|
|
6798
|
-
if (args.length === 0) return val;
|
|
6799
6827
|
const url = new URL(val);
|
|
6800
|
-
|
|
6801
|
-
url.searchParams.
|
|
6828
|
+
if (args.length === 0) {
|
|
6829
|
+
const keys = Array.from(url.searchParams.keys());
|
|
6830
|
+
keys.forEach((key) => {
|
|
6831
|
+
url.searchParams.delete(key);
|
|
6832
|
+
});
|
|
6833
|
+
} else {
|
|
6834
|
+
for (const paramName of args) {
|
|
6835
|
+
url.searchParams.delete(paramName);
|
|
6836
|
+
}
|
|
6802
6837
|
}
|
|
6803
6838
|
return url.toString();
|
|
6804
6839
|
}
|
|
@@ -6903,6 +6938,7 @@ var Transformers = class _Transformers {
|
|
|
6903
6938
|
JSONTransformer,
|
|
6904
6939
|
Length,
|
|
6905
6940
|
NumberTransformer,
|
|
6941
|
+
RemoveLastPathSection,
|
|
6906
6942
|
RemoveUrlQueryParam,
|
|
6907
6943
|
ResolveTransformer,
|
|
6908
6944
|
Trim,
|