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

Preserve URL Query Parameters #348

Open
morganney opened this issue Dec 31, 2022 · 2 comments
Open

Preserve URL Query Parameters #348

morganney opened this issue Dec 31, 2022 · 2 comments

Comments

@morganney
Copy link

morganney commented Dec 31, 2022

Is there any way to preserve query parameters other than ?module and ?meta when requesting a package? I've noticed that adding any other query parameter will result in a 302 redirect removing the query from the url.

My use case is to provide the ability to define an HTML custom element with a custom name upon loading. Currently my project uses a name query parameter from the import specifier to allow clients to customize the name used for the element.

Request: GET https://unpkg.com/tts-element@0.0.2-beta/dist/text-to-speech/defined.js?name=tts-ele
Response: 302 Location: /tts-element@0.0.2-beta/dist/text-to-speech/defined.js

Are arbitrary query parameters not supported, or am I just missing something? The closest I've seen in regards to this issue is #93.

@morganney
Copy link
Author

As a workaround I can provide documentation that suggests using another CDN, for example JSDelivr works without removing query parameters.

GET https://cdn.jsdelivr.net/npm/tts-element@0.0.2-beta/dist/text-to-speech/defined.js?name=my-tts returns a 200 allowing my element to work as expected when loaded with a query parameter in the specifier.

@clshortfuse
Copy link

I've noticed this as well. My web framework parses import.meta.url and applies the theme based on input

jsdeliver does work:

import { Button } from 'https://cdn.jsdelivr.net/npm/@shortfuse/materialdesignweb@0.7.1-7/dist/index.min.js?color=6750A4&custom=yellow,orange:orange,green:0f0,alias:aqua&lightness=auto';

But as described, unpkg will do a 302 redirect without the URL parameters.

It seems this is intentional:

export default function allowQuery(validKeys = []) {

Perhaps we add a special argument that force unpkg to pass arguments? Something like url?unpkgQuery&customParams=foo?

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

No branches or pull requests

2 participants