Skip to content

Commit

Permalink
Set default version to latest with mike 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 15, 2023
1 parent 97eb435 commit 811f4f5
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,33 @@

<script>
window.onload = function () {
// Delay the redirection until the Google Analytics script is loaded.
// Function to get a query parameter from the URL
function getQueryParam(name) {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name);
}

// Check if the current URL already has a utm_referrer parameter
var existingReferrer = getQueryParam('utm_referrer');

var encodedReferrer = '';

if (existingReferrer) {
// Use the existing utm_referrer value for the redirect
var encodedReferrer = encodeURIComponent(existingReferrer);
} else {
// If there's no utm_referrer parameter in the URL, use document.referrer
var referrer = document.referrer;

// Check if both the URL parameter and document.referrer are empty
if (referrer && !document.referrer.includes("faststream.airt.ai")) {
var encodedReferrer = encodeURIComponent(referrer);
}
}

// Redirect to href and include the referrer as a query parameter
window.location.replace(
"latest/" + window.location.search + window.location.hash // nosemgrep
"latest/" + (encodedReferrer ? '?utm_referrer=' + encodedReferrer : '') + window.location.hash
);
};
</script>
Expand Down

0 comments on commit 811f4f5

Please sign in to comment.