Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function escapeRegExp(str) {
- var escaped = str.replace(/([.+?^=!:${}()|[]/\])/g, "\$1");
- console.log("escaped " + escaped);
- return escaped;
- }
- function matchUrl() {
- var currentUrl = window.location.toString();
- var loginUrl = "https://*.testsite123.io/testsite123/portal/#/login";
- return currentUrl.match(new RegExp(escapeRegExp(loginUrl), 'g'));
- }
- console.log("window.location " + window.location.toString());
- console.log("match " + matchUrl());
- window.location https://prod.testsite123.io/testsite123/portal/#/login
- escaped https://*.testsite123.io/testsite123/portal/#/login
- match null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement