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

Allow @ in resolved redirect URLs #1347

Closed
sqs opened this issue Dec 11, 2023 · 3 comments
Closed

Allow @ in resolved redirect URLs #1347

sqs opened this issue Dec 11, 2023 · 3 comments
Labels
enhancement ✨ New feature or request

Comments

@sqs
Copy link

sqs commented Dec 11, 2023

Description

My intent is for Vike to redirect /npm/* to https://cdn.jsdelivr.net/npm/*, but this breaks when the * parameter matches something containing @. This is common in this use case because the * is matching npm package names (eg @my-team/my-package).

I see that resolveRouteStringRedirect forbids resolved URLs in redirection that contain @. Is that restriction necessary?

My vite.config.ts is:

export default defineConfig({
    plugins: [
        // ...
        vike({
            redirects: {
                '/npm/*': 'https://cdn.jsdelivr.net/npm/*',
            },
        }),
  // ...

I get the following error:

Error: [vike][Wrong Usage] URL should not contain "@" unless it is a mailto link.
    at resolveRouteStringRedirect (file:///Users/sqs/src/github.com/sourcegraph/opencodegraph/node_modules/.pnpm/vike@0.4.150_vite@5.0.4/node_modules/vike/dist/esm/shared/route/resolveRedirects.js:38:9)

It works if I throw redirect(...) in an +onBeforeRender.ts file, but I would prefer to specify it in config (because, and this might be a misperception, that then it will actually redirect at the HTTP layer even in static page hosts).

p.s. Thank you for Vike! It is awesome.

@sqs sqs added the enhancement ✨ New feature or request label Dec 11, 2023
@brillout
Copy link
Member

Fix pre-released as 0.4.150-commit-d9acc70.

Thank you for Vike! It is awesome.

I'm glad you're enjoying it. Would your company be up for sponsoring?

@sqs
Copy link
Author

sqs commented Dec 11, 2023

Thank you so much!

Re: sponsoring, yes, absolutely, assuming we end up using the site that I've built with Vike. I have put a calendar reminder on myself for next week to confirm, at which point I will sponsor if we are indeed using it by then. If not, I'll probably sponsor it personally.

@brillout
Copy link
Member

Thank you Quinn. We're beyond thrilled by the prospect of being sponsored by Sourcegraph. Fingers crossed 🤞

the site that I've built with Vike

Let us know if you stumble upon any other blockers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants