diff options
author | Joris Roovers <joris.roovers@gmail.com> | 2023-05-12 10:44:41 +0000 |
---|---|---|
committer | Joris Roovers <joris.roovers@gmail.com> | 2023-05-12 10:44:41 +0000 |
commit | 42b78fe2e909193b4460d83eeb1dd7692c74afe0 (patch) | |
tree | 519b53b434b07b5a167f7fbfa10c1f56270b3f2d | |
parent | d2a704fdd11b78e246e36b3bb89d9983c5a67e38 (diff) |
404 redirect
Attempting to auto-redirect to latest for all URLs.
-rw-r--r-- | 404.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/404.html b/404.html new file mode 100644 index 0000000..4e55ec1 --- /dev/null +++ b/404.html @@ -0,0 +1,11 @@ +<script> + // Check if the current path is versioned, if not, redirect to the default versioned path + const defaultVersion = "latest" + const basePath = "/gitlint"; + const versionedBasePath = `${basePath}/${defaultVersion}`; + if (!window.location.pathname.startsWith(versionedBasePath)){ + // Replace only the first occurence of the base path with the versioned base path + // Replace it in href, so we keep hashes and query params + window.location.href = window.location.href.replace(basePath, versionedBasePath); + } +</script>
\ No newline at end of file |