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

Make URLs a generic type #16

Open
eliassjogreen opened this issue Oct 15, 2024 · 0 comments
Open

Make URLs a generic type #16

eliassjogreen opened this issue Oct 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@eliassjogreen
Copy link
Member

Currently the URLs can get quite messy in cases where we support both relative, server and absolute urls. E.g:

...
    input:
      | `${"http://" | "https://"}${string}/api/v1/${string}/subscription/plan/${string}/subscribe/`
      | `/api/v1/${string}/subscription/plan/${string}/subscribe/`,
...

It would be nice if these types would look like:

TypedURL<`/api/v1/${string}/subscription/plan/${string}/subscribe/`>

This could then be generated per-project like:

export type TypedURL<T extends string> =
      | `https://example.com/${T}`               // Include each server URL here
      | `http://${string}${T}` 			     	 // Include only when absolute http URLs are enabled
      | `https://${string}${T}` 				 // Include only when absolute https URLs are enabled
      | T; 										 // Include only when relative URLs are enabled
@eliassjogreen eliassjogreen added the enhancement New feature or request label Oct 15, 2024
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

1 participant