Skip to content

Commit

Permalink
patch: Handle absolute url
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Nov 13, 2017
1 parent e073690 commit 0b7d912
Show file tree
Hide file tree
Showing 4 changed files with 1,051 additions and 1,224 deletions.
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { join } = require('path')
const rp = require('request-promise-native')
const stdMocks = require('std-mocks')
const enableDestroy = require('server-destroy')
const isAbsoluteUrl = require('is-absolute-url')

let port = 8000

Expand Down Expand Up @@ -54,7 +55,10 @@ exports.stop = (server) => {
})
}

const url = (path) => `http://localhost:${port}` + join('/', (path || ''))
const url = (path) => {
if (typeof path === 'string' && isAbsoluteUrl(path)) return path
return `http://localhost:${port}` + join('/', (path || ''))
}
exports.url = url

exports.$get = (path, options) => {
Expand Down
Loading

0 comments on commit 0b7d912

Please sign in to comment.