Skip to content

Commit

Permalink
Merge pull request #219 from amadeus4dev/underscript
Browse files Browse the repository at this point in the history
Test within `script` block
  • Loading branch information
minjikarin authored Jan 10, 2024
2 parents fc7412d + d2fbcd9 commit 3722e2c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
-#}

{% extends "base.html" %}
{% block extrahead %}
{% block scripts %}
<script>
if (window.location.hostname === 'amadeus4dev.github.io') {
// console.log(window.location.hostname);
const path = window.location.pathname;
const redirectPattern = /^\/([^/]+)/;
const redirectUrl = path.replace(redirectPattern, 'https://developers.amadeus.com/self-service/apis-docs/guides/$1');
document.write(`<meta http-equiv="refresh" content="0;url=${redirectUrl}" />`);
}

// Add event listener to all links starting with developers.amadeus.com
document.querySelectorAll('a[href^="https://developers.amadeus.com"]').forEach(link => {
link.addEventListener('click', function (e) {
e.preventDefault(); // Prevent the default action (navigating to the link)
window.location.href = this.href; // Manually redirect the page to the link
});
});
</script>
{% endblock %}

0 comments on commit 3722e2c

Please sign in to comment.