Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

How to apply redirect rules to a path? #417

Open
swamidass opened this issue Feb 19, 2022 · 2 comments
Open

How to apply redirect rules to a path? #417

swamidass opened this issue Feb 19, 2022 · 2 comments

Comments

@swamidass
Copy link

How can I read in redirect rules in node, and then apply those rules to a URL to see what URL it will be redirected to?

@ehmicky
Copy link
Contributor

ehmicky commented Feb 21, 2022

Hi @swamidass,

The short answer is: this is unfortunately not easy to do at the moment.

A longer answer: this library is only concerned with loading and normalizing redirect rules, not applying them to URLs. Internally, Netlify uses another library for it: netlify-redirector. This is for example what we use in Netlify CLI (link to code). Unfortunately, that library is currently undocumented (and hasn't been updated in 3 years).

@swamidass
Copy link
Author

Thanks for the info.

A minimal example that shows reading in the redirects, and then applying netlify-redirector to a rule would be great to see.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants