@jsenv/urls 2.5.4 → 2.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/urls",
3
- "version": "2.5.4",
3
+ "version": "2.6.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/main.js CHANGED
@@ -4,6 +4,7 @@ export { DATA_URL } from "./data_url.js";
4
4
  export { stringifyUrlSite } from "./url_trace.js";
5
5
  export {
6
6
  asUrlWithoutSearch,
7
+ asSpecifierWithoutSearch,
7
8
  isValidUrl,
8
9
  normalizeUrl,
9
10
  injectQueryParamsIntoSpecifier,
package/src/url_utils.js CHANGED
@@ -23,6 +23,14 @@ export const isValidUrl = (url) => {
23
23
  }
24
24
  };
25
25
 
26
+ export const asSpecifierWithoutSearch = (specifier) => {
27
+ if (isValidUrl(specifier)) {
28
+ return asUrlWithoutSearch(specifier);
29
+ }
30
+ const [beforeQuestion] = specifier.split("?");
31
+ return beforeQuestion;
32
+ };
33
+
26
34
  // normalize url search params:
27
35
  // Using URLSearchParams to alter the url search params
28
36
  // can result into "file:///file.css?css_module"