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.
@@ -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 = isFileLink(src) && resolveFileUrl(src, filePath)
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 = isFileLink(src) && resolveFileUrl(src, filePath)
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 isFileLink(href) {
117
- return !/^(http|https|mailto):/.test(href)
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "1.53.0",
3
+ "version": "1.53.1",
4
4
  "description": "imdone-core",
5
5
  "main": "index.js",
6
6
  "scripts": {