@rspress/runtime 1.36.0 → 1.37.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/utils.d.ts +1 -0
- package/dist/utils.js +5 -1
- package/package.json +4 -4
- package/src/utils.ts +5 -5
package/dist/utils.d.ts
CHANGED
@@ -5,4 +5,5 @@ export declare function removeBase(url: string): string;
|
|
5
5
|
export declare function isEqualPath(a: string, b: string): boolean;
|
6
6
|
export declare function normalizeHrefInRuntime(a: string): string;
|
7
7
|
export declare function normalizeImagePath(imagePath: string): string;
|
8
|
+
export declare function isAbsoluteUrl(path: string): boolean;
|
8
9
|
export { addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction };
|
package/dist/utils.js
CHANGED
@@ -32,7 +32,7 @@ function normalizeImagePath(imagePath) {
|
|
32
32
|
if (!isProd) {
|
33
33
|
return imagePath;
|
34
34
|
}
|
35
|
-
if (
|
35
|
+
if (isAbsoluteUrl(imagePath)) {
|
36
36
|
return imagePath;
|
37
37
|
}
|
38
38
|
if (!imagePath.startsWith("/")) {
|
@@ -40,8 +40,12 @@ function normalizeImagePath(imagePath) {
|
|
40
40
|
}
|
41
41
|
return withBase(imagePath);
|
42
42
|
}
|
43
|
+
function isAbsoluteUrl(path) {
|
44
|
+
return isExternalUrl(path) || isDataUrl(path) || path.startsWith("//");
|
45
|
+
}
|
43
46
|
export {
|
44
47
|
addLeadingSlash,
|
48
|
+
isAbsoluteUrl,
|
45
49
|
isEqualPath,
|
46
50
|
isProduction,
|
47
51
|
normalizeHrefInRuntime,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/runtime",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.37.0",
|
4
4
|
"description": "The Runtime of Rspress Documentation Framework",
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
6
6
|
"repository": {
|
@@ -28,11 +28,11 @@
|
|
28
28
|
"react": "^18.3.1",
|
29
29
|
"react-dom": "^18.3.1",
|
30
30
|
"react-helmet-async": "^1.3.0",
|
31
|
-
"react-router-dom": "^6.
|
32
|
-
"@rspress/shared": "1.
|
31
|
+
"react-router-dom": "^6.28.0",
|
32
|
+
"@rspress/shared": "1.37.0"
|
33
33
|
},
|
34
34
|
"devDependencies": {
|
35
|
-
"@modern-js/tsconfig": "2.
|
35
|
+
"@modern-js/tsconfig": "2.62.0",
|
36
36
|
"@types/jest": "~29.5.14",
|
37
37
|
"@types/react": "^18.3.12",
|
38
38
|
"@types/react-dom": "^18.3.1",
|
package/src/utils.ts
CHANGED
@@ -43,11 +43,7 @@ export function normalizeImagePath(imagePath: string) {
|
|
43
43
|
if (!isProd) {
|
44
44
|
return imagePath;
|
45
45
|
}
|
46
|
-
if (
|
47
|
-
isExternalUrl(imagePath) ||
|
48
|
-
isDataUrl(imagePath) ||
|
49
|
-
imagePath.startsWith('//')
|
50
|
-
) {
|
46
|
+
if (isAbsoluteUrl(imagePath)) {
|
51
47
|
return imagePath;
|
52
48
|
}
|
53
49
|
// only append base to internal non-relative urls
|
@@ -58,4 +54,8 @@ export function normalizeImagePath(imagePath: string) {
|
|
58
54
|
return withBase(imagePath);
|
59
55
|
}
|
60
56
|
|
57
|
+
export function isAbsoluteUrl(path: string) {
|
58
|
+
return isExternalUrl(path) || isDataUrl(path) || path.startsWith('//');
|
59
|
+
}
|
60
|
+
|
61
61
|
export { addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction };
|