Last active
February 13, 2024 20:05
-
-
Save ialphan/5ae8bd0dce5bbb4dea79b65d2482934c to your computer and use it in GitHub Desktop.
Remove trailing slash in nuxt 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function ({path, query, hash}) { | |
if (path === "/" || !path.endsWith("/")) return; | |
const nextPath = path.replace(/\/+$/, "") || "/", | |
nextRoute = {path: nextPath, query, hash}; | |
return navigateTo(nextRoute, {redirectCode: 308}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment