Explorar el Código

remove `images/`-prefix from detected images

Stephan Fuchs hace 2 meses
padre
commit
75890a4689
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  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;