Dominic Barnes
Dominic Barnes

Reputation: 28439

Sammy.js - Get path from within route

I'm learning Sammy.js and using it to build a mini-application on top of a REST API I'm working on. I couldn't find this immediately, and I am probably missing something.

I'm using routes like:

this.get("/databases/:name", function () { ... });

I basically want to take the route path and pass it along to my REST API, since they largely match up anyways. I've inspected this within the callback, and found a property called path that contains the full path, including the filename. (i.e. /index.html#/databases/foo)

All I care about is what comes after the #, and I wonder if there is something baked in so I don't have to use this.path.split("#")[1].

Upvotes: 2

Views: 2838

Answers (1)

mu is too short
mu is too short

Reputation: 434695

You could just look at window.location.hash and strip off the leading #. That should be pretty much the same as pulling information out of this.path.

Upvotes: 3

Related Questions