Mulitple slashes inside a url param

2,350 views
Skip to first unread message

Geoff Flarity

unread,
May 17, 2011, 5:22:30 PM5/17/11
to Express
Hi,

I'm trying to find a way to include slashes in the last param in a
route description.

Say I have something like this in my app:

app.put('/:db/:doc_id/:attachment?' ...)

I'd like it to match something like:

/foo/bar/bin/baz/bop.txt

such that

req.params.doc_id contains 'bar' and
req.params.attachment contains 'bin/baz/bop.txt'

Before I try writing a full regex , is there an easier way to
accomplish this?

Cheers,
Geoff

vision media [ Tj Holowaychuk ]

unread,
May 17, 2011, 5:31:02 PM5/17/11
to expre...@googlegroups.com
yup, :foo matches a single segment only, however "*" can span several. so either:

   /:db/:doc_id/*

using req.params[0], or

   /:db/:doc_id/:attachment(*)

using req.params.attachment


--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.




--
Tj Holowaychuk
Vision Media
President & Creative Lead
Reply all
Reply to author
Forward
0 new messages