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): duplicated router.base when using context.redirect(object) #5290

Merged
merged 1 commit into from
Mar 20, 2019
Merged

fix(vue-app): duplicated router.base when using context.redirect(object) #5290

merged 1 commit into from
Mar 20, 2019

Conversation

niandalu
Copy link

When router.base provided, context.redirect(object) leads to a path with duplicated router.base.

Reproduction: https://github.com/niandalu/nuxt-bug

  1. Ensure router.base present in nuxt.config.js
  2. Run the example above, browse http://localhost:3000/foo
  3. Click incorrect, it will lead you to /foo/foo/target rather than /foo/target

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

What I did is just changing router.resolve().href to router.resove().fullName.

router.resolve().href is the combination of router.base and resolved.fullPath. Also Nuxt is prepending router.base to urls. So the final url generated contains duplicated router.base.

Although this change mutates the behavior of context.redirect, it should be ok:

  1. For users having router.base blank, same as before
  2. For users having router.base set, original context.redirect(object) doesn't function correctly. So they shouldn't have context.redirect(object) in codebase

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.

@manniL manniL requested a review from clarkdo March 20, 2019 10:49
@codecov-io
Copy link

Codecov Report

Merging #5290 into dev will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              dev   #5290      +/-   ##
=========================================
+ Coverage   95.66%   95.7%   +0.03%     
=========================================
  Files          74      74              
  Lines        2513    2513              
  Branches      639     639              
=========================================
+ Hits         2404    2405       +1     
+ Misses         92      91       -1     
  Partials       17      17
Impacted Files Coverage Δ
packages/vue-renderer/src/renderer.js 92.07% <0%> (+0.49%) ⬆️

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 ef41e20...5e1cb7c. Read the comment docs.

@Atinux Atinux self-requested a review March 20, 2019 11:41
@Atinux Atinux changed the title fix: duplicated router.base when router.base given fix(vue-app): duplicated router.base when using context.redirect(object) Mar 20, 2019
@manniL manniL mentioned this pull request Mar 20, 2019
@pi0 pi0 merged commit cf02e82 into nuxt:dev Mar 20, 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.

None yet

5 participants