浏览代码

remove `images/`-prefix from detected images

Stephan Fuchs 2 月之前
父节点
当前提交
75890a4689
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/defaultProcess.js

+ 4 - 1
src/defaultProcess.js

@@ -11,7 +11,10 @@ export default function defaultProcess(code){
     const imageRegex = /<<='(?:<center>)?<img (?:'\+\(QSP\.\$set_imgh\[0\]\)\+' )?src="([\w\s/]+\.jpg)">(?:<\/center>)?'>>/gi;
     twineCodeTemp = twineCode;
     while(regexResult = imageRegex.exec(twineCode)) {
-        twineCodeTemp = twineCodeTemp.replace(regexResult[0],`<<image '${regexResult[1]}'>>`);
+        let imagePath = regexResult[1];
+        if(imagePath.startsWith('images/') && imagePath.length > 7)
+            imagePath = imagePath.substring(7);
+        twineCodeTemp = twineCodeTemp.replace(regexResult[0],`<<image '${imagePath}'>>`);
     }
     twineCode = twineCodeTemp;