Skip to content

Commit

Permalink
fix for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
rajbos committed Aug 21, 2024
1 parent 524c6c8 commit 2123ba9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,32 @@
// Redirect to the correct URL
var pathname = window.location.pathname;
var search = window.location.search;

// Remove leading slash from pathname if it exists
if (pathname.startsWith('/')) {
pathname = pathname.substring(1);
}

// Construct the new URL
let basePath = '/copilot-videos/#' + pathname.replace('copilot-videos', '');
// If there are double slashes anywhere in the url, remove one
console.log(`pathname: ${basePath}`);

// Construct the new URL (only needed for forks with a subfolder, should not be used on https://github-copilot.xebia.ms!)
let basePath = '/';
if (!pathname.startsWith('https://github-copilot.xebia.ms')) {
// Redirect to the root of the fork
basePath = '/copilot-videos/#' + pathname.replace('copilot-videos', '');
}

// If there are double slashes anywhere in the url, remove them
if (basePath.includes('//')) {
basePath = basePath.replace('//', '/');
}
// log the parts for debugging
console.log(`search: ${search}`);
console.log(`pathname: ${basePath}`);
console.log(`basePath: ${basePath}`);

// Build the new URL
const url = search ? basePath + search : basePath;
console.log(`redirecting to url: ${url}`);

// Redirect to the new URL
window.location.href = url;
</script>
Expand Down

0 comments on commit 2123ba9

Please sign in to comment.