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: correctly remove import query from url #854

Merged
merged 2 commits into from Feb 26, 2022
Merged

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Feb 25, 2022

Fixes #836

@netlify
Copy link

netlify bot commented Feb 25, 2022

✔️ Deploy Preview for vitest-dev ready!

🔨 Explore the source changes: 3472ca6

🔍 Inspect the deploy log: https://app.netlify.com/sites/vitest-dev/deploys/6219cb6e0e62cd0008879560

😎 Browse the preview: https://deploy-preview-854--vitest-dev.netlify.app

@@ -19,7 +19,7 @@ export function normalizeId(id: string, base?: string): string {
.replace(/^(node|file):/, '')
.replace(/^\/+/, '/') // remove duplicate leading slashes
.replace(/[?&]v=\w+/, '?') // remove ?v= query
.replace(/\?import/, '') // remove ?import query
.replace(/[?&]import/, '?') // remove ?import query
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it would be better to replace ?import by ? and &import by &? I don't know if having two ? in the URL will end up confusing Vite 🤔

Suggested change
.replace(/[?&]import/, '?') // remove ?import query
.replace(/([&?])(import)/,'$1') // remove ?import query

@antfu antfu merged commit 38c5c8d into main Feb 26, 2022
@antfu antfu deleted the sheremet-va/fix-import branch February 26, 2022 06:40
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.

Unit test be failed with component contain svg
3 participants