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: splitFileAndPostfix works as cleanUrl #12572

Merged
merged 8 commits into from Mar 26, 2023
Merged

fix: splitFileAndPostfix works as cleanUrl #12572

merged 8 commits into from Mar 26, 2023

Conversation

patak-dev
Copy link
Member

Description

cleanUrl and splitFileAndPostfix where working in different ways.

cleanUrl('/hello#hash?query') -> '/hello'
splitFileAndPostfix('/hello#hash?query') -> '/hello#hash'

This PR makes cleanUrl make them both work in the same way, possibly fixing issues with dependencies having # in their path. The new cleanUrl also avoids the second regex if it isn't needed.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@stackblitz
Copy link

stackblitz bot commented Mar 24, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev added the performance Performance related enhancement label Mar 24, 2023
@patak-dev
Copy link
Member Author

Looks like cleanUrl is right, first the hash needs to be removed, and then the query. If not new URL calls we do later on won't work correctly (like in injectQuery).

new URL('https://bar.com#foo?hello').hash === '#foo?hello'
new URL('https://bar.com#foo?hello').search === ''

I think the original splitFileAndPostfix having these inverted may not have been intentional . Probably the intention at that point was to remove both the query and the hash.

Later on, this ended up helping with paths like es5-ext/array/#/concat.

@patak-dev
Copy link
Member Author

patak-dev commented Mar 24, 2023

The PR now makes splitFileAndPostfix work as cleanUrl instead.

@patak-dev
Copy link
Member Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Mar 24, 2023

📝 Ran ecosystem CI: Open

suite result
astro ❌ failure
histoire ❌ failure
iles ❌ failure
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ✅ success
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-pages ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ✅ success
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success
windicss ✅ success

@patak-dev patak-dev changed the title refactor: cleanUrl works as splitFileAndPostfix refactor: splitFileAndPostfix works as cleanUrl Mar 24, 2023
@patak-dev
Copy link
Member Author

/ecosystem-ci run astro iles

@patak-dev
Copy link
Member Author

/ecosystem-ci run iles

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Mar 25, 2023

📝 Ran ecosystem CI: Open

suite result
iles ❌ failure

@patak-dev patak-dev mentioned this pull request Mar 25, 2023
4 tasks
@patak-dev patak-dev changed the title refactor: splitFileAndPostfix works as cleanUrl fix: splitFileAndPostfix works as cleanUrl Mar 25, 2023
@patak-dev
Copy link
Member Author

Marking this as a fix. I think we should do it, but I'm not sure if in 4.3.

@patak-dev patak-dev added p3-minor-bug An edge case that only affects very specific usage (priority) and removed performance Performance related enhancement labels Mar 25, 2023
@patak-dev
Copy link
Member Author

It looks like the Iles fail isn't related to this PR, it was failing in others too (cc @ElMassimo in case you have some time to check with the current Vite main).

@bluwy if the Astro fail is because of flakiness, I think we could merge this PR in 4.3.

@patak-dev patak-dev requested a review from bluwy March 26, 2023 10:32
@bluwy
Copy link
Member

bluwy commented Mar 26, 2023

I'm not sure if it's a fluke since it's a new error I haven't seen before. re-running again

@bluwy
Copy link
Member

bluwy commented Mar 26, 2023

/ecosystem-ci run astro

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Mar 26, 2023

📝 Ran ecosystem CI: Open

suite result
astro ✅ success

@bluwy
Copy link
Member

bluwy commented Mar 26, 2023

So I believe this is how the behaviour had changed:

fsPath original fs refactor pr
foo?bar#baz foo?bar#baz - foo?bar#baz
foo#bar?baz foo#bar?baz - foo#bar + ?baz
foo?bar - - -
foo#bar foo#bar foo#bar foo#bar

The fs refactor PR might've caused a regression, so this PR seems to be on the right track, but with only one change for the second case. I think this PR should be fine then 👍

bluwy
bluwy previously approved these changes Mar 26, 2023
@patak-dev
Copy link
Member Author

I think you are right, looks like the logic the fs refactor wasn't right. I now updated this PR to ignore foo?bar#baz, we don't need to check that one.

fsPath original fs refactor pr
foo?bar#baz foo?bar#baz - -
foo#bar?baz foo#bar?baz - foo#bar + ?baz
foo?bar - - -
foo#bar foo#bar foo#bar foo#bar

bluwy
bluwy previously approved these changes Mar 26, 2023
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

The new handling sounds good to me too 👍 I have one tiny nit, but this is good after that.

packages/vite/src/node/plugins/resolve.ts Outdated Show resolved Hide resolved
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@patak-dev patak-dev merged commit 276725f into main Mar 26, 2023
12 checks passed
@patak-dev patak-dev deleted the refactor/cleanUrl branch March 26, 2023 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants