replace quoted file path to avoid name conflicts in filename and folder nesting.
This commit is contained in:
		
							parent
							
								
									e5554cbc60
								
							
						
					
					
						commit
						0f3eab743d
					
				
					 1 changed files with 7 additions and 4 deletions
				
			
		|  | @ -249,16 +249,18 @@ class PreviewFrame extends React.Component { | ||||||
|     jsFileStrings.forEach((jsFileString) => { |     jsFileStrings.forEach((jsFileString) => { | ||||||
|       if (jsFileString.match(MEDIA_FILE_QUOTED_REGEX)) { |       if (jsFileString.match(MEDIA_FILE_QUOTED_REGEX)) { | ||||||
|         const filePath = jsFileString.substr(1, jsFileString.length - 2); |         const filePath = jsFileString.substr(1, jsFileString.length - 2); | ||||||
|  |         const quoteCharacter = jsFileString.substr(0, 1); | ||||||
|         const resolvedFile = resolvePathToFile(filePath, files); |         const resolvedFile = resolvePathToFile(filePath, files); | ||||||
|  | 
 | ||||||
|         if (resolvedFile) { |         if (resolvedFile) { | ||||||
|           if (resolvedFile.url) { |           if (resolvedFile.url) { | ||||||
|             newContent = newContent.replace(filePath, resolvedFile.url); |             newContent = newContent.replace(jsFileString, quoteCharacter + resolvedFile.url + quoteCharacter); | ||||||
|           } else if (resolvedFile.name.match(PLAINTEXT_FILE_REGEX)) { |           } else if (resolvedFile.name.match(PLAINTEXT_FILE_REGEX)) { | ||||||
|             // could also pull file from API instead of using bloburl |             // could also pull file from API instead of using bloburl | ||||||
|             const blobURL = getBlobUrl(resolvedFile); |             const blobURL = getBlobUrl(resolvedFile); | ||||||
|             this.props.setBlobUrl(resolvedFile, blobURL); |             this.props.setBlobUrl(resolvedFile, blobURL); | ||||||
|             const filePathRegex = new RegExp(filePath, 'gi'); | 
 | ||||||
|             newContent = newContent.replace(filePathRegex, blobURL); |             newContent = newContent.replace(jsFileString, quoteCharacter + blobURL + quoteCharacter); | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  | @ -274,10 +276,11 @@ class PreviewFrame extends React.Component { | ||||||
|     cssFileStrings.forEach((cssFileString) => { |     cssFileStrings.forEach((cssFileString) => { | ||||||
|       if (cssFileString.match(MEDIA_FILE_QUOTED_REGEX)) { |       if (cssFileString.match(MEDIA_FILE_QUOTED_REGEX)) { | ||||||
|         const filePath = cssFileString.substr(1, cssFileString.length - 2); |         const filePath = cssFileString.substr(1, cssFileString.length - 2); | ||||||
|  |         const quoteCharacter = cssFileString.substr(0, 1); | ||||||
|         const resolvedFile = resolvePathToFile(filePath, files); |         const resolvedFile = resolvePathToFile(filePath, files); | ||||||
|         if (resolvedFile) { |         if (resolvedFile) { | ||||||
|           if (resolvedFile.url) { |           if (resolvedFile.url) { | ||||||
|             newContent = newContent.replace(filePath, resolvedFile.url); |             newContent = newContent.replace(cssFileString, quoteCharacter + resolvedFile.url + quoteCharacter); | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Dan Hoizner
						Dan Hoizner