Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Using the landingpage parameter

ㅤ edited this page Nov 28, 2019 · 1 revision

If the landingpage parameter is used, permanentdetour redirects patrons to that landing page, and passes the final destination url as the url parameter dest.

Carleton is using the following js snippet on the landing page to create links from that url param:

<p>
  <a id="omnilink" href="https://ocul-crl.primo.exlibrisgroup.com/discovery/search">Omni Search Interface</a></p>
</p>
<script>
try {
  let parsedWindowLocation = new URL(window.location.href);
  let dest = parsedWindowLocation.searchParams.get("dest");
  if (dest !== null) {
    let parsedDest = new URL(dest);
    if (parsedDest.origin !== "https://ocul-crl.primo.exlibrisgroup.com") {
      throw new Error("Incorrect destination origin.");
    }
    if (!["/discovery/search", "/discovery/login", "/discovery/fulldisplay", "/discovery/browse"].includes(parsedDest.pathname)) {
      throw new Error("Incorrect destination pathname.");
    }
    for (let key of parsedDest.searchParams.keys()) {
      if (!["mode", "vid", "docid", "browseScope", "browseQuery", "sortby", "mfacet", "query"].includes(key)) {
        throw new Error("Incorrect destination parameter.");
      }
    }
    if (parsedDest.hash !== "") {
      throw new Error("Destination hash not allowed.");
    }
    let link = document.getElementById("omnilink");
    link.textContent = parsedDest.toString();
    link.href = parsedDest.toString();
  }
} catch (e) {
  console.log(e.message);
}
</script>

Clone this wiki locally