Merge pull request #316 from dead-horse/parseurl

use parseurl
This commit is contained in:
TJ Holowaychuk 2014-07-14 08:19:25 -07:00
commit 2a040da429
2 changed files with 8 additions and 10 deletions

View file

@ -3,13 +3,12 @@
* Module dependencies. * Module dependencies.
*/ */
var stringify = require('url').format;
var typer = require('media-typer');
var parse = require('parseurl');
var qs = require('querystring'); var qs = require('querystring');
var typeis = require('type-is'); var typeis = require('type-is');
var fresh = require('fresh'); var fresh = require('fresh');
var url = require('url');
var typer = require('media-typer');
var stringify = url.format;
var parse = url.parse;
/** /**
* Prototype. * Prototype.
@ -79,8 +78,7 @@ module.exports = {
*/ */
get path() { get path() {
var c = this._pathcache = this._pathcache || {}; return parse(this.req).pathname;
return c[this.url] || (c[this.url] = parse(this.url).pathname);
}, },
/** /**
@ -91,7 +89,7 @@ module.exports = {
*/ */
set path(path) { set path(path) {
var url = parse(this.url); var url = parse(this.req);
url.pathname = path; url.pathname = path;
this.url = stringify(url); this.url = stringify(url);
}, },
@ -130,8 +128,7 @@ module.exports = {
*/ */
get querystring() { get querystring() {
var c = this._qscache = this._qscache || {}; return parse(this.req).query || '';
return c[this.url] || (c[this.url] = parse(this.url).query || '');
}, },
/** /**
@ -142,7 +139,7 @@ module.exports = {
*/ */
set querystring(str) { set querystring(str) {
var url = parse(this.url); var url = parse(this.req);
url.search = str; url.search = str;
this.url = stringify(url); this.url = stringify(url);
}, },

View file

@ -38,6 +38,7 @@
"dethroy": "~1.0.0", "dethroy": "~1.0.0",
"error-inject": "~1.0.0", "error-inject": "~1.0.0",
"vary": "~0.1.0", "vary": "~0.1.0",
"parseurl": "~1.1.3",
"only": "0.0.2" "only": "0.0.2"
}, },
"devDependencies": { "devDependencies": {