Skip to content

Commit 461e24b

Browse files
committed
Fix regex
1 parent ac2cfe5 commit 461e24b

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

browser/main/lib/dataApi/attachmentManagement.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -713,24 +713,30 @@ function replaceNoteKeyWithNewNoteKey(noteContent, oldNoteKey, newNoteKey) {
713713
*/
714714
function removeStorageAndNoteReferences(input, noteKey) {
715715
return input.replace(
716-
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|])', 'g'),
716+
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|\\))', 'g'),
717717
function(match) {
718-
const temp = match
719-
.replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep)
720-
.replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep)
721-
.replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep)
722-
.replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.sep)
723-
return temp.replace(
724-
new RegExp(
725-
STORAGE_FOLDER_PLACEHOLDER +
726-
'(' +
727-
escapeStringRegexp(path.sep) +
728-
noteKey +
729-
')?',
730-
'g'
731-
),
732-
DESTINATION_FOLDER
733-
)
718+
return match
719+
.replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.posix.sep)
720+
.replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.posix.sep)
721+
.replace(
722+
new RegExp(escapeStringRegexp(path.win32.sep), 'g'),
723+
path.posix.sep
724+
)
725+
.replace(
726+
new RegExp(escapeStringRegexp(path.posix.sep), 'g'),
727+
path.posix.sep
728+
)
729+
.replace(
730+
new RegExp(
731+
STORAGE_FOLDER_PLACEHOLDER +
732+
'(' +
733+
escapeStringRegexp(path.sep) +
734+
noteKey +
735+
')?',
736+
'g'
737+
),
738+
DESTINATION_FOLDER
739+
)
734740
}
735741
)
736742
}

0 commit comments

Comments
 (0)