aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/karma/lib/middleware/strip_host.js
blob: 6851b779a5719ebb1308016acd1a0b756d173e19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * Strip host middleware is responsible for stripping hostname from request path
 * This to handle requests that uses (normally over proxies) an absolutURI as request path
 */

var createStripHostMiddleware = function () {
  return function (request, response, next) {
    function stripHostFromUrl (url) {
      return url.replace(/^http[s]?:\/\/([a-z\-\.\:\d]+)\//, '/')
    }

    request.normalizedUrl = stripHostFromUrl(request.url) || request.url
    next()
  }
}

// PUBLIC API
exports.create = createStripHostMiddleware