Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function escapeRegExp(str) {
  2. var escaped = str.replace(/([.+?^=!:${}()|[]/\])/g, "\$1");
  3. console.log("escaped " + escaped);
  4. return escaped;
  5. }
  6. function matchUrl() {
  7. var currentUrl = window.location.toString();
  8. var loginUrl = "https://*.testsite123.io/testsite123/portal/#/login";
  9. return currentUrl.match(new RegExp(escapeRegExp(loginUrl), 'g'));
  10. }
  11.  
  12. console.log("window.location " + window.location.toString());
  13. console.log("match " + matchUrl());
  14.  
  15. window.location https://prod.testsite123.io/testsite123/portal/#/login
  16. escaped https://*.testsite123.io/testsite123/portal/#/login
  17. match null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement