From fd019688ecc981fe2d7f871ebdbb894baa3026de Mon Sep 17 00:00:00 2001 From: dead_horse Date: Mon, 14 Jul 2014 17:57:03 +0800 Subject: [PATCH] use parseurl --- lib/request.js | 17 +++++++---------- package.json | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/request.js b/lib/request.js index 276fd50..2047016 100644 --- a/lib/request.js +++ b/lib/request.js @@ -3,13 +3,12 @@ * Module dependencies. */ +var stringify = require('url').format; +var typer = require('media-typer'); +var parse = require('parseurl'); var qs = require('querystring'); var typeis = require('type-is'); var fresh = require('fresh'); -var url = require('url'); -var typer = require('media-typer'); -var stringify = url.format; -var parse = url.parse; /** * Prototype. @@ -79,8 +78,7 @@ module.exports = { */ get path() { - var c = this._pathcache = this._pathcache || {}; - return c[this.url] || (c[this.url] = parse(this.url).pathname); + return parse(this.req).pathname; }, /** @@ -91,7 +89,7 @@ module.exports = { */ set path(path) { - var url = parse(this.url); + var url = parse(this.req); url.pathname = path; this.url = stringify(url); }, @@ -130,8 +128,7 @@ module.exports = { */ get querystring() { - var c = this._qscache = this._qscache || {}; - return c[this.url] || (c[this.url] = parse(this.url).query || ''); + return parse(this.req).query || ''; }, /** @@ -142,7 +139,7 @@ module.exports = { */ set querystring(str) { - var url = parse(this.url); + var url = parse(this.req); url.search = str; this.url = stringify(url); }, diff --git a/package.json b/package.json index 4dce4e0..7146e3a 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "dethroy": "~1.0.0", "error-inject": "~1.0.0", "vary": "~0.1.0", + "parseurl": "~1.1.3", "only": "0.0.2" }, "devDependencies": {