@jsenv/urls 2.4.0 → 2.4.1

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.4.0",
3
+ "version": "2.4.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,6 @@
28
28
  "test": "node --conditions=development ./scripts/test.mjs"
29
29
  },
30
30
  "dependencies": {
31
- "@jsenv/humanize": "1.2.5"
31
+ "@jsenv/humanize": "1.2.6"
32
32
  }
33
33
  }
package/src/main.js CHANGED
@@ -40,3 +40,5 @@ export { urlToPathname } from "./url_to_pathname.js";
40
40
  export { urlToRelativeUrl } from "./url_to_relative_url.js";
41
41
  export { urlToResource } from "./url_to_resource.js";
42
42
  export { urlToScheme } from "./url_to_scheme.js";
43
+
44
+ export { getCommonPathname } from "./common_pathname.js";
@@ -1,6 +1,10 @@
1
1
  import { getCommonPathname } from "./common_pathname.js";
2
2
 
3
- export const urlToRelativeUrl = (url, baseUrl) => {
3
+ export const urlToRelativeUrl = (
4
+ url,
5
+ baseUrl,
6
+ { preferRelativeNotation } = {},
7
+ ) => {
4
8
  const urlObject = new URL(url);
5
9
  const baseUrlObject = new URL(baseUrl);
6
10
 
@@ -44,7 +48,7 @@ export const urlToRelativeUrl = (url, baseUrl) => {
44
48
  }
45
49
 
46
50
  const relativeUrl = `${specificPathname}${search}${hash}`;
47
- return relativeUrl;
51
+ return preferRelativeNotation ? `./${relativeUrl}` : relativeUrl;
48
52
  };
49
53
 
50
54
  const pathnameToParentPathname = (pathname) => {