jcubic / wayne

Service Worker Routing library for in browser HTTP requests
https://jcubic.github.io/wayne
MIT License
556 stars 29 forks source link

Support ignore case sensitive when match route #38

Closed jonsam-ng closed 2 months ago

jonsam-ng commented 3 months ago

What will be like?

app.get('/message', function(req, res) {
  res.text('Lorem Ipsum');
}, { ignoreCaseSensitive: true });

when ignoreCaseSensitive param provided, we can match routes like /message or /MESSAGE that case not sensitive any more.

Why we need this?

Sometime we want to match some requests that url case pattern not sure, but we know case not sensitive on service. So we don't need to register paths for all different cases.

/restapi/v1/getUsers
/restapi/v1/getusers
jcubic commented 3 months ago

Do you think you need this per route? There are already options for Wayne constructor, I can add the option there. What you think?

jonsam-ng commented 3 months ago

I would prefer to 'ignoreCaseSensitive' per route because I'm not sure if the corresponding service is case sensitive. Registering a case-insensitive route allows me to easily respond to different styles of requests without having to register multiple times.

jcubic commented 2 months ago

In version 0.17.0 there is an option: caseSensitive:

app.get('/message', (req, res) => {
    res.json({ message: 'Hello' });
}, { caseSensitive: false });