@jsenv/urls 1.2.8 → 2.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/move_url.js +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/urls",
3
- "version": "1.2.8",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/move_url.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { urlToRelativeUrl } from "./url_to_relative_url.js"
2
2
 
3
- export const moveUrl = ({ url, from, to, preferAbsolute = false }) => {
3
+ export const moveUrl = ({ url, from, to, preferRelative }) => {
4
4
  let relativeUrl = urlToRelativeUrl(url, from)
5
5
  if (relativeUrl.slice(0, 2) === "//") {
6
6
  // restore the protocol
7
7
  relativeUrl = new URL(relativeUrl, url).href
8
8
  }
9
9
  const absoluteUrl = new URL(relativeUrl, to).href
10
- if (preferAbsolute) {
11
- return absoluteUrl
10
+ if (preferRelative) {
11
+ return urlToRelativeUrl(absoluteUrl, to)
12
12
  }
13
- return urlToRelativeUrl(absoluteUrl, to)
13
+ return absoluteUrl
14
14
  }