Skip to content

Commit

Permalink
SPA redirect on 404
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronAsAChimp committed Dec 21, 2023
1 parent 746ab81 commit c44e8ba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions image-lint-web/web/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>404</title>
<script type="module">
let url = window.location.pathname;

if (window.location.search) {
url += window.location.search;
}

if (window.location.hash) {
url += window.location.hash;
}

window.location = '/?url=' + encodeURIComponent(url);
</script>
</head>
<body></body>
</html>
5 changes: 5 additions & 0 deletions image-lint-web/web/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import ImlDropzone from '../components/iml-dropzone.vue';

import '../css/index.css';

const params = new URLSearchParams(window.location.search);

if (params.has('url')) {
window.history.replaceState(null, null, decodeURIComponent(params.get('url')));
}

const body = document.body;
const rootEl = document.createElement('div');
Expand Down

0 comments on commit c44e8ba

Please sign in to comment.