Skip to content

fix(utils): error when router.trailingSlash is false #6515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2019
Merged

fix(utils): error when router.trailingSlash is false #6515

merged 1 commit into from
Oct 8, 2019

Conversation

y-temp4
Copy link

@y-temp4 y-temp4 commented Oct 4, 2019

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Fix #6501

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@codecov-io
Copy link

codecov-io commented Oct 4, 2019

Codecov Report

Merging #6515 into dev will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #6515   +/-   ##
=======================================
  Coverage   95.67%   95.67%           
=======================================
  Files          79       79           
  Lines        2706     2706           
  Branches      698      698           
=======================================
  Hits         2589     2589           
  Misses        101      101           
  Partials       16       16
Flag Coverage Δ
#e2e 100% <ø> (ø) ⬆️
#fixtures 50.59% <0%> (ø) ⬆️
#unit 92.35% <100%> (-0.04%) ⬇️
Impacted Files Coverage Δ
packages/utils/src/route.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7688825...34d8f12. Read the comment docs.

@@ -177,6 +177,9 @@ export const createRoutes = function createRoutes ({
if (trailingSlash !== undefined) {
route.pathToRegexpOptions = { ...route.pathToRegexpOptions, strict: true }
route.path = route.path.replace(/\/+$/, '') + (trailingSlash ? '/' : '')
if (route.path === '') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about?
route.path = route.path.replace(/\/+$/, '') + (trailingSlash ? '/' : '') || '/'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.
I'll adopt this way, thx!

@pi0 pi0 requested a review from TheAlexLichter October 5, 2019 14:30
@TheAlexLichter
Copy link
Member

LGTM! We should definitely make sure that users don't trip here like I did 🙈 - #6339

@pi0 pi0 changed the title fix: error of router.trailingSlash fix(utils): fix error when router.trailingSlash is false Oct 8, 2019
@pi0 pi0 changed the title fix(utils): fix error when router.trailingSlash is false fix(utils): error when router.trailingSlash is false Oct 8, 2019
@pi0 pi0 merged commit 2d27a4d into nuxt:dev Oct 8, 2019
@pi0 pi0 mentioned this pull request Oct 8, 2019
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

router.trailingSlash: false "This page could not be found"
6 participants