marked-base-url 1.0.2 → 1.0.4

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/lib/index.cjs CHANGED
@@ -4,7 +4,8 @@ function baseUrl(base) {
4
4
  // extension code here
5
5
 
6
6
  base = base.trim().replace(/\/+$/, '/'); // if multiple '/' at the end, just keep one
7
- const isBaseAbsolute = /^[\w+]+:\/\//.test(base);
7
+ const reIsAbsolute = /^[\w+]+:\/\//;
8
+ const isBaseAbsolute = reIsAbsolute.test(base);
8
9
  const dummyUrl = 'http://__dummy__';
9
10
  const dummyBaseUrl = new URL(base, dummyUrl);
10
11
  const dummyUrlLength = dummyUrl.length + (base.startsWith('/') ? 0 : 1);
@@ -15,6 +16,11 @@ function baseUrl(base) {
15
16
  return;
16
17
  }
17
18
 
19
+ if (reIsAbsolute.test(token.href)) {
20
+ // the URL is absolute, do not touch it
21
+ return;
22
+ }
23
+
18
24
  if (isBaseAbsolute) {
19
25
  try {
20
26
  token.href = new URL(token.href, base).href;
package/lib/index.umd.js CHANGED
@@ -8,7 +8,8 @@
8
8
  // extension code here
9
9
 
10
10
  base = base.trim().replace(/\/+$/, '/'); // if multiple '/' at the end, just keep one
11
- const isBaseAbsolute = /^[\w+]+:\/\//.test(base);
11
+ const reIsAbsolute = /^[\w+]+:\/\//;
12
+ const isBaseAbsolute = reIsAbsolute.test(base);
12
13
  const dummyUrl = 'http://__dummy__';
13
14
  const dummyBaseUrl = new URL(base, dummyUrl);
14
15
  const dummyUrlLength = dummyUrl.length + (base.startsWith('/') ? 0 : 1);
@@ -19,6 +20,11 @@
19
20
  return;
20
21
  }
21
22
 
23
+ if (reIsAbsolute.test(token.href)) {
24
+ // the URL is absolute, do not touch it
25
+ return;
26
+ }
27
+
22
28
  if (isBaseAbsolute) {
23
29
  try {
24
30
  token.href = new URL(token.href, base).href;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marked-base-url",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "marked base url",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./src/index.js",
@@ -39,26 +39,26 @@
39
39
  },
40
40
  "homepage": "https://github.com/markedjs/marked-base-url#readme",
41
41
  "peerDependencies": {
42
- "marked": "^4 || ^5"
42
+ "marked": "^4 || ^5 || ^6"
43
43
  },
44
44
  "devDependencies": {
45
- "@babel/core": "^7.22.8",
46
- "@babel/preset-env": "^7.22.7",
45
+ "@babel/core": "^7.22.9",
46
+ "@babel/preset-env": "^7.22.9",
47
47
  "@semantic-release/changelog": "^6.0.3",
48
48
  "@semantic-release/commit-analyzer": "^10.0.1",
49
49
  "@semantic-release/git": "^10.0.1",
50
- "@semantic-release/github": "^9.0.3",
50
+ "@semantic-release/github": "^9.0.4",
51
51
  "@semantic-release/npm": "^10.0.4",
52
52
  "@semantic-release/release-notes-generator": "^11.0.4",
53
53
  "babel-jest": "^29.6.1",
54
- "eslint": "^8.44.0",
54
+ "eslint": "^8.46.0",
55
55
  "eslint-config-standard": "^17.1.0",
56
- "eslint-plugin-import": "^2.27.5",
56
+ "eslint-plugin-import": "^2.28.0",
57
57
  "eslint-plugin-n": "^16.0.1",
58
58
  "eslint-plugin-promise": "^6.1.1",
59
- "jest-cli": "^29.6.1",
60
- "marked": "^5.1.0",
61
- "rollup": "^3.26.0",
59
+ "jest-cli": "^29.6.2",
60
+ "marked": "^6.0.0",
61
+ "rollup": "^3.27.0",
62
62
  "semantic-release": "^21.0.7"
63
63
  }
64
64
  }
package/src/index.js CHANGED
@@ -2,7 +2,8 @@ export function baseUrl(base) {
2
2
  // extension code here
3
3
 
4
4
  base = base.trim().replace(/\/+$/, '/'); // if multiple '/' at the end, just keep one
5
- const isBaseAbsolute = /^[\w+]+:\/\//.test(base);
5
+ const reIsAbsolute = /^[\w+]+:\/\//;
6
+ const isBaseAbsolute = reIsAbsolute.test(base);
6
7
  const dummyUrl = 'http://__dummy__';
7
8
  const dummyBaseUrl = new URL(base, dummyUrl);
8
9
  const dummyUrlLength = dummyUrl.length + (base.startsWith('/') ? 0 : 1);
@@ -13,6 +14,11 @@ export function baseUrl(base) {
13
14
  return;
14
15
  }
15
16
 
17
+ if (reIsAbsolute.test(token.href)) {
18
+ // the URL is absolute, do not touch it
19
+ return;
20
+ }
21
+
16
22
  if (isBaseAbsolute) {
17
23
  try {
18
24
  token.href = new URL(token.href, base).href;