Skip to content
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

fix(vue-app): remove trailing slash in vue-router non-strict mode #5746

Merged
merged 2 commits into from
May 17, 2019

Conversation

clarkdo
Copy link
Member

@clarkdo clarkdo commented May 15, 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 #5593

According to https://github.com/vuejs/vue-router/blob/dev/src/create-route-map.js#L167 , vue-router will remove the trailing slash in non strict mode.

Imagine we have routes like and there is NuxtChild and NuxtLink to='/test/post/1' in pages/test.vue:

In non-strict mode, after we click link, the route.matched[0] is always { path: '/test', ... }

{
  path: "/test",
  name: "test",
  children: [{
    path: "post/:slug"
  }]
}

When we access http://localhost:3000/test, routerViewKey is always /test before and after clicking link.

But if we access http://localhost:3000/test/, the routerViewKey is /test/ from this.route.path. After clicking link, the routerViewKey is /test from this.$route.matched[0].path, so test.vue will be destroyed and recreated which is incorrect.

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.

@clarkdo clarkdo requested review from pimlie and pi0 May 15, 2019 13:06
@codecov-io
Copy link

codecov-io commented May 15, 2019

Codecov Report

Merging #5746 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##             dev   #5746   +/-   ##
=====================================
  Coverage   95.6%   95.6%           
=====================================
  Files         82      82           
  Lines       2662    2662           
  Branches     683     683           
=====================================
  Hits        2545    2545           
  Misses        98      98           
  Partials      19      19

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 c2c2945...e6d2f8f. Read the comment docs.

@clarkdo clarkdo requested a review from Atinux May 15, 2019 14:02
Co-Authored-By: Alexander Lichter <manniL@gmx.net>
@pi0 pi0 requested a review from manniL May 16, 2019 08:28
Copy link

@galvez galvez left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Modal post doesn't open inside index route but it does in different routes
6 participants