Browse Source

remove `images/`-prefix from detected images

Stephan Fuchs 2 months ago
parent
commit
75890a4689
1 changed files with 4 additions and 1 deletions
  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;