Skip to content

fix!: prepend router base - #339

Merged
pi0 merged 4 commits into
nuxt:mainfrom
btkostner:router-base
Jun 30, 2021
Merged

fix!: prepend router base#339
pi0 merged 4 commits into
nuxt:mainfrom
btkostner:router-base

Conversation

@btkostner

Copy link
Copy Markdown
Contributor

This fixes #338 but is a breaking change due to how URLs are handled.

If you have a default router base of /:
/images/test.png points to ~/static/images/test.png and outputs /_nuxt/image/hash.png in the HTML (no difference.)

If you have a router base of /app/:
/images/test.png points to ~/static/images/test.png and would output /app/_nuxt/image/hash.png in the HTML. This is different from the current implementation that would require you to do /app/images/test.png to generate correctly.

If you have a router base of /app/ with external url:
https://example.com/test.png points to an external URL and outputs /app/_nuxt/image/hash.png in the HTML.

Alternative way to do this

We could remove the changes in ipx.ts. Specifying the src for images would be the same as it is now, but it would resolve correctly after being built. This would not be a breaking change.

@codecov-commenter

codecov-commenter commented Jun 25, 2021

Copy link
Copy Markdown

Codecov Report

Merging #339 (1dc311d) into main (58dd744) will decrease coverage by 0.09%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
- Coverage   58.81%   58.71%   -0.10%     
==========================================
  Files          26       26              
  Lines         607      608       +1     
  Branches      190      192       +2     
==========================================
  Hits          357      357              
- Misses        250      251       +1     
Impacted Files Coverage Δ
src/generate.ts 3.44% <0.00%> (-0.13%) ⬇️
src/runtime/providers/ipx.ts 100.00% <100.00%> (ø)

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 58dd744...1dc311d. Read the comment docs.

@pi0 pi0 changed the title fix: fix router base breaking nuxt generate fix(ipx): prepend router base Jun 29, 2021

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for PR. LGTM.

Comment thread src/generate.ts Outdated
@pi0
pi0 requested a review from danielroe June 29, 2021 17:08
@btkostner

Copy link
Copy Markdown
Contributor Author

Sorry about the force push. I accidentally merged in master branch instead of main. Should be all fixed now

@pi0 pi0 changed the title fix(ipx): prepend router base fix!: prepend router base Jun 30, 2021
@pi0
pi0 merged commit 2d7a04d into nuxt:main Jun 30, 2021
procrates pushed a commit to procrates/nuxt-image that referenced this pull request Feb 21, 2023
@github-actions github-actions Bot mentioned this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Images not generated with router.base defined

4 participants