Skip to content

Instantly share code, notes, and snippets.

@ialphan
Last active February 13, 2024 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ialphan/5ae8bd0dce5bbb4dea79b65d2482934c to your computer and use it in GitHub Desktop.
Save ialphan/5ae8bd0dce5bbb4dea79b65d2482934c to your computer and use it in GitHub Desktop.
Remove trailing slash in nuxt 3
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