JS: Show problem with new RegExp().exec()

This commit is contained in:
Asger F
2024-12-04 13:57:24 +01:00
parent ef833de60e
commit f6d0835c64

View File

@@ -6,7 +6,7 @@ window.location = /.*redirect=([^&]*).*/.exec(document.location.href)[1];
window.location = indirect.exec(document.location.href)[1];
});
// NOT OK
// NOT OK [INCONSISTENCY]
window.location = new RegExp('.*redirect=([^&]*).*').exec(document.location.href)[1];
(function(){
@@ -14,7 +14,7 @@ window.location = new RegExp('.*redirect=([^&]*).*').exec(document.location.href
window.location = indirect.exec(document.location.href)[1];
});
// NOT OK
// NOT OK [INCONSISTENCY]
window.location = new RegExp(/.*redirect=([^&]*).*/).exec(document.location.href)[1];
(function(){
@@ -23,7 +23,7 @@ window.location = new RegExp(/.*redirect=([^&]*).*/).exec(document.location.href
});
function foo(win) {
win.location.assign(new RegExp(/.*redirect=([^&]*).*/).exec(win.location.href)[1]); // NOT OK
win.location.assign(new RegExp(/.*redirect=([^&]*).*/).exec(win.location.href)[1]); // NOT OK [INCONSISTENCY]
}
foo(window);
foo(window);