Chris
Chris

Reputation: 8432

sammy.js : camel case urls

How can I force sammy.js to recognize a url /Brief to be the same as /brief?

this.get('/brief', function(context) {
    console.log("BRIEF");
});

I have my CMS setup to generate lower case urls, however if a user types in a url with a camel case format I get the error:

Tue Mar 19 2013 15:39:31 GMT+1100 (AUS Eastern Daylight Time)] body 404 Not Found get /Brief  Error {message: "404 Not Found get /Brief "} 

The page still loads fine, but Sammy.js won't activate the module for that route.

Upvotes: 4

Views: 659

Answers (1)

js1568
js1568

Reputation: 7032

You can use a case insensitive regex expression to match any case of alpha characters:

this.get(/\/brief/i, function(context) {
    console.log("BRIEF");
});

Upvotes: 4

Related Questions