req.url.dirname

STRING, read-only.

Available in all subroutines.

The directories specified in a URL. This will be from the beginning of the URL up to the last /, not including the query string. The last / will not be part of req.url.dirname unless req.url.dirname is / (the root directory).

Examples

In the request www.example.com/1/hello.gif?foo=bar, req.url.dirname will contain /1.

In the request www.example.com/5/inner/hello.gif?foo=bar, req.url.dirname will contain /5/inner.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.