Fix legacy name prefix removal using wrong variable in bookmarks Fixes leftover bug from #4993. In both `getBookmarkName` and `createBranch`, the second regex replacement was incorrectly using the original `name` variable instead of the already-cleaned `cleanName` variable, causing the legacy prefix removal to fail.
| @@ -88,7 +88,7 @@ async function getBookmarkName({ isReplace = false, forceName = null } = {}) { | |||
| 88 | // Strip off existing suffixes, then build new name | 88 | // Strip off existing suffixes, then build new name |
| 89 | let cleanName = name.replace(new RegExp(` - ${bookmarkNameToken}\\d+$`), ''); | 89 | let cleanName = name.replace(new RegExp(` - ${bookmarkNameToken}\\d+$`), ''); |
| 90 | // Strip off legacy old name prefix too | 90 | // Strip off legacy old name prefix too |
| 91 | cleanName = name.replace(new RegExp(`^${bookmarkNameToken}\\d+ - `), ''); | 91 | cleanName = cleanName.replace(new RegExp(`^${bookmarkNameToken}\\d+ - `), ''); |
| 92 | return `${cleanName} - ${bookmarkNameToken}${i}`; | 92 | return `${cleanName} - ${bookmarkNameToken}${i}`; |
| 93 | } | 93 | } |
| 94 | const existingChats = await getExistingChatNames(); | 94 | const existingChats = await getExistingChatNames(); |
| @@ -183,7 +183,7 @@ export async function createBranch(mesId) { | |||
| 183 | // Strip off existing suffixes, then build new name | 183 | // Strip off existing suffixes, then build new name |
| 184 | let cleanName = name.replace(/ - Branch #\d+$/, ''); | 184 | let cleanName = name.replace(/ - Branch #\d+$/, ''); |
| 185 | // Strip off legacy old name prefix too | 185 | // Strip off legacy old name prefix too |
| 186 | cleanName = name.replace(/^Branch #\d+ - /, ''); | 186 | cleanName = cleanName.replace(/^Branch #\d+ - /, ''); |
| 187 | return `${cleanName} - Branch #${i}`; | 187 | return `${cleanName} - Branch #${i}`; |
| 188 | } | 188 | } |
| 189 | const existingChats = await getExistingChatNames(); | 189 | const existingChats = await getExistingChatNames(); |