https://github.com/jrop/express-resolve-url
https://github.com/jrop/express-resolve-url
expressjs nodejs resolver url
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jrop/express-resolve-url
- Owner: jrop
- Created: 2016-04-01T22:36:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-01T17:27:25.000Z (almost 9 years ago)
- Last Synced: 2026-01-14T14:42:10.135Z (6 months ago)
- Topics: expressjs, nodejs, resolver, url
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
express-resolve-url
===================
> Resolve URLs easily in express.js
# Installation
```sh
npm i --save express-resolve-url
```
# Use
```js
const express = require('express')
const resolveUrl = require('express-resolve-url')
/*
* Setup a sub-sub-app
*/
const subSubApp = express()
.use(resolveUrl())
.get('/', function (req, res) {
res.end('The URL for /goo (from the sub-sub-app) is: ' + req.resolveUrl('/goo'))
// => /sub-app/sub-app/goo
})
/*
* Setup a sub-app
*/
const subApp = express()
.use(resolveUrl())
.use('/sub-app', subSubApp)
.get('/', function (req, res) {
res.end('The URL for /goo (from the sub-app) is: ' + req.resolveUrl('/goo'))
// => /sub-app/goo
})
/*
* Setup the root-app
*/
const app = express()
.use(resolveUrl())
.use('/sub-app', subApp)
.get('/', function (req, res) {
res.end('The URL for /goo (from the root-app) is: ' + req.resolveUrl('/goo'))
// => /goo
})
```
# License
ISC License (ISC) Copyright (c) 2016, Jonathan Apodaca jrapodaca@gmail.com
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.