Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

nodejs express - case sensitive URL's

nodejs express - case sensitive URL's

Problem

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 ??

Problem courtesy of: clarkk

Solution

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);
Solution courtesy of: Ilan Frumer

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

nodejs express - case sensitive URL's

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×