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

new URL(url, import.meta.url) does not work when query parameters are present #13017

Closed
7 tasks done
benmccann opened this issue Apr 26, 2023 · 0 comments · Fixed by #13034
Closed
7 tasks done

new URL(url, import.meta.url) does not work when query parameters are present #13017

benmccann opened this issue Apr 26, 2023 · 0 comments · Fixed by #13034
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@benmccann
Copy link
Collaborator

benmccann commented Apr 26, 2023

Describe the bug

The following does not work because of the query parameter:

const demo = (x) => new URL(`/sample/${x}/example.jpg?abc`, import.meta.url).href

If you remove ?abc then it works again.

Here are the docs for this feature: https://vitejs.dev/guide/assets.html#new-url-url-import-meta-url

And the code for the feature: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/assetImportMetaUrl.ts

Query parameters are needed to support vite-imagetools

#11157 is potentially related, but it's unclear if it's the same issue

Reproduction

https://github.com/benmccann/import.meta.url-with-query-params

Steps to reproduce

Run npm install followed by npm run dev

System Info

npmPackages:
    vite: ^4.3.2 => 4.3.3

Used Package Manager

npm

Logs

No response

Validations

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant