@@ -227,15 +227,7 @@ function migrateAttachments (markdownContent, storagePath, noteKey) {
227
227
* @returns {String } postprocessed HTML in which all :storage references are mapped to the actual paths.
228
228
*/
229
229
function fixLocalURLS ( renderedHTML , storagePath ) {
230
- /*
231
- A :storage reference is like `:storage/3b6f8bd6-4edd-4b15-96e0-eadc4475b564/f939b2c3.jpg`.
232
-
233
- - `STORAGE_FOLDER_PLACEHOLDER` will match `:storage`
234
- - `(?:(?:\\\/|%5C)[\\w.]+)+` will match `/3b6f8bd6-4edd-4b15-96e0-eadc4475b564/f939b2c3.jpg`
235
- - `(?:\\\/|%5C)[\\w.]+` will either match `/3b6f8bd6-4edd-4b15-96e0-eadc4475b564` or `/f939b2c3.jpg`
236
- - `(?:\\\/|%5C)` match the path seperator. `\\\/` for posix systems and `%5C` for windows.
237
- */
238
- return renderedHTML . replace ( new RegExp ( '/?' + STORAGE_FOLDER_PLACEHOLDER + '(?:(?:\\\/|%5C)[\\w.]+)+' , 'g' ) , function ( match ) {
230
+ return renderedHTML . replace ( new RegExp ( '/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?"' , 'g' ) , function ( match ) {
239
231
var encodedPathSeparators = new RegExp ( mdurl . encode ( path . win32 . sep ) + '|' + mdurl . encode ( path . posix . sep ) , 'g' )
240
232
return match . replace ( encodedPathSeparators , path . sep ) . replace ( new RegExp ( '/?' + STORAGE_FOLDER_PLACEHOLDER , 'g' ) , 'file:///' + path . join ( storagePath , DESTINATION_FOLDER ) )
241
233
} )
@@ -429,7 +421,14 @@ function replaceNoteKeyWithNewNoteKey (noteContent, oldNoteKey, newNoteKey) {
429
421
* @returns {String } Input without the references
430
422
*/
431
423
function removeStorageAndNoteReferences ( input , noteKey ) {
432
- return input . replace ( new RegExp ( mdurl . encode ( path . sep ) , 'g' ) , path . sep ) . replace ( new RegExp ( STORAGE_FOLDER_PLACEHOLDER + '(' + escapeStringRegexp ( path . sep ) + noteKey + ')?' , 'g' ) , DESTINATION_FOLDER )
424
+ return input . replace ( new RegExp ( '/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|])' , 'g' ) , function ( match ) {
425
+ const temp = match
426
+ . replace ( new RegExp ( mdurl . encode ( path . win32 . sep ) , 'g' ) , path . sep )
427
+ . replace ( new RegExp ( mdurl . encode ( path . posix . sep ) , 'g' ) , path . sep )
428
+ . replace ( new RegExp ( escapeStringRegexp ( path . win32 . sep ) , 'g' ) , path . sep )
429
+ . replace ( new RegExp ( escapeStringRegexp ( path . posix . sep ) , 'g' ) , path . sep )
430
+ return temp . replace ( new RegExp ( STORAGE_FOLDER_PLACEHOLDER + '(' + escapeStringRegexp ( path . sep ) + noteKey + ')?' , 'g' ) , DESTINATION_FOLDER )
431
+ } )
433
432
}
434
433
435
434
/**
0 commit comments