Skip to content
Myr

Use url.resolve to compute location header of relative paths

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jérémy Lal · committed by Jérémy Lal · parent 6619147 · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:lib/response.js+5 added-4 removed
12 unmodified lines
13 , statusCodes = http.STATUS_CODES14 , cookie = require('cookie')15 , send = require('send')16 , mime = connect.mime17 , resolve = require('url').resolve18 , basename = path.basename19 , extname = path.extname;2021/**
611 unmodified lines
633 */634635res.location = function(url){636 var app = this.app636 , req = this.req;637 , req = this.req638 , path;639640 // setup redirect map641 var map = { back: req.get('Referrer') || '/' };642
1 unmodified line
644 url = map[url] || url;645646 // relative647 if (!~url.indexOf('://') && 0 != url.indexOf('//')) {646 var path;647648 // relative to path649 if ('.' == url[0]) {650 path = req.originalUrl.split('?')[0];651 url = path + ('/' == path[path.length - 1] ? '' : '/') + url;651 path = path + ('/' == path[path.length - 1] ? '' : '/');652 url = resolve(path, url);653 // relative to mount-point654 } else if ('/' != url[0]) {655 path = app.path();656 url = path + '/' + url;
147 unmodified lines