imdone-core 1.53.0 → 1.53.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/lib/adapters/markdown.js +9 -4
- package/package.json +1 -1
package/lib/adapters/markdown.js
CHANGED
|
@@ -83,7 +83,7 @@ function replaceImagePaths(filePath) {
|
|
|
83
83
|
const srcIndex = token.attrIndex('src');
|
|
84
84
|
if (srcIndex >= 0) {
|
|
85
85
|
const src = token.attrs[srcIndex][1];
|
|
86
|
-
const srcUrl =
|
|
86
|
+
const srcUrl = !isUrl(src) && resolveFileUrl(src, filePath)
|
|
87
87
|
if (srcUrl) token.attrs[srcIndex][1] = srcUrl;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -104,7 +104,7 @@ function replaceLinkPaths(filePath) {
|
|
|
104
104
|
const srcIndex = token.attrIndex('href');
|
|
105
105
|
if (srcIndex >= 0) {
|
|
106
106
|
const src = token.attrs[srcIndex][1];
|
|
107
|
-
const srcUrl =
|
|
107
|
+
const srcUrl = !isUrl(src) && resolveFileUrl(src, filePath)
|
|
108
108
|
if (srcUrl) token.attrs[srcIndex][1] = srcUrl;
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -113,8 +113,13 @@ function replaceLinkPaths(filePath) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
function
|
|
117
|
-
|
|
116
|
+
function isUrl(href) {
|
|
117
|
+
try {
|
|
118
|
+
new URL(href);
|
|
119
|
+
return true;
|
|
120
|
+
} catch (e) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
function resolveFileUrl(src, filePath) {
|