Skip to content

Commit

Permalink
and another one
Browse files Browse the repository at this point in the history
  • Loading branch information
rajbos committed Aug 21, 2024
1 parent 4f909db commit 019ce70
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
45 changes: 1 addition & 44 deletions public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,7 @@
<!DOCTYPE html>
<html>
<head>
<script>
// 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);
}
console.log(`pathname: ${pathname}`);

// Determine the base path based on the hostname
let basePath = '';
if (window.location.hostname === 'github-copilot.xebia.ms') {
basePath = pathname + '/#';
} else {
basePath = '/copilot-videos/#' + pathname.replace('copilot-videos/', '');
}

// Get the search up to the first slash or question mark
let searchBeginning = search.split(/[/?]/)[0];
if (basePath.includes(searchBeginning)) {
// Remove the search from the basePath
search = search.replace(searchBeginning, '');
}

// 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(`basePath: ${basePath}`);

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

// Redirect to the new URL only if it's different from the current URL
if (!window.location.href.includes(url)) {
window.location.href = url;
}
</script>
<meta http-equiv="refresh" content="0; URL=/#/404" />
</head>
<body>
</body>
Expand Down
1 change: 1 addition & 0 deletions src/pages/NotFound.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

const NotFound = () => {
console.log('NotFound component rendered');
return (
<div>
Not found
Expand Down

0 comments on commit 019ce70

Please sign in to comment.