nodejs express - case sensitive URL's

clarkk picture clarkk · Jan 19, 2014 · Viewed 11.8k times · Source

How to make URL's case sensitive?

app.get()

app.get('/([a-z]{2}/)api*', function(request, response){});

Here this app.get() catch both /EN/api /eN/api

What can I do so it only catches lower case URL's like /en/api ??

Answer

Ilan Frumer picture Ilan Frumer · Jan 19, 2014

From express.js api docs

case sensitive routing - Enable case sensitivity, disabled by default, treating "/Foo" and "/foo" as the same

You can change the defaults like so:

app.set('case sensitive routing', true);