1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-12 17:26:17 +00:00

Fix regex

This commit is contained in:
Junyoung Choi
2020-04-16 00:07:45 +09:00
parent ac2cfe5169
commit 461e24bf39

View File

@@ -713,24 +713,30 @@ function replaceNoteKeyWithNewNoteKey(noteContent, oldNoteKey, newNoteKey) {
*/
function removeStorageAndNoteReferences(input, noteKey) {
return input.replace(
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|])', 'g'),
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|\\))', 'g'),
function(match) {
const temp = match
.replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep)
.replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep)
.replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep)
.replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.sep)
return temp.replace(
new RegExp(
STORAGE_FOLDER_PLACEHOLDER +
'(' +
escapeStringRegexp(path.sep) +
noteKey +
')?',
'g'
),
DESTINATION_FOLDER
)
return match
.replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.posix.sep)
.replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.posix.sep)
.replace(
new RegExp(escapeStringRegexp(path.win32.sep), 'g'),
path.posix.sep
)
.replace(
new RegExp(escapeStringRegexp(path.posix.sep), 'g'),
path.posix.sep
)
.replace(
new RegExp(
STORAGE_FOLDER_PLACEHOLDER +
'(' +
escapeStringRegexp(path.sep) +
noteKey +
')?',
'g'
),
DESTINATION_FOLDER
)
}
)
}