Merge pull request #4616 from callmetushar123/master

urlincrement/decrement should operate on decodedURI Fix #3792
This commit is contained in:
Oliver Blanthorn 2023-03-10 16:32:08 +00:00 committed by GitHub
commit 12fcc25efe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,8 +11,10 @@
* @return the incremented URL, or null if cannot be incremented
*/
export function incrementUrl(url, count) {
const url_en=decodeURI(url)
const regex = /(.*?)(\d+)(\D*)$/
// Find the final number in a URL
const matches = url.match(/(.*?)(\d+)(\D*)$/)
const matches = regex.exec(url_en)
// no number in URL - nothing to do here
if (matches === null) {
@ -25,13 +27,13 @@ export function incrementUrl(url, count) {
// Re-pad numbers that were zero-padded to be the same length:
// 0009 + 1 => 0010
if (number.match(/^0/)) {
if ((/^0/).exec(number)) {
while (newNumberStr.length < number.length) {
newNumberStr = "0" + newNumberStr
}
}
return pre + newNumberStr + post
return encodeURI(pre + newNumberStr + post)
}
/** Get the root of a URL