samedi 25 mai 2019

Redirect user if url matches certain conditions

I'd like the user to be redirected to a new webpage if the url contains certain conditions. I can't seem to get the OR condition to work. Any thoughts?

if (
    document.location.href.indexOf("https://www.oct.ca/") > -1 &&
    document.location.href.indexOf("professionally_speaking") > -1 &&
    document.location.href.includes("2019-03" || "2018-12")
  ) {
    window.location = window.location.href.replace("https://www.oct.ca/", "http://professionallyspeaking.oct.ca/")

  }

Aucun commentaire:

Enregistrer un commentaire