[Pkg-javascript-commits] [node-mocks-http] 91/296: added mockRequest.originalUrl
Thorsten Alteholz
alteholz at moszumanska.debian.org
Mon Feb 8 18:13:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
alteholz pushed a commit to branch master
in repository node-mocks-http.
commit b699c0d590632c35765e45ef4f0f67dd4d31f356
Author: Johnny Estilles <johnny.estilles at agentia.asia>
Date: Sun Mar 8 00:40:38 2015 +0800
added mockRequest.originalUrl
---
lib/mockRequest.js | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/mockRequest.js b/lib/mockRequest.js
index 229f9d2..1ddc122 100644
--- a/lib/mockRequest.js
+++ b/lib/mockRequest.js
@@ -22,10 +22,11 @@
*
* Options:
*
- * method - The method value, see <mockRequest._setMethod>
- * url - The url value, see <mockRequest._setURL>
- * params - The parameters, see <mockRequest._setParam>
- * body - The body values, , see <mockRequest._setBody>
+ * method - The method value, see <mockRequest._setMethod>
+ * url - The url value, see <mockRequest._setURL>
+ * originalUrl - The originalUrl value, see <mockRequest._setOriginalUrl>
+ * params - The parameters, see <mockRequest._setParam>
+ * body - The body values, , see <mockRequest._setBody>
*/
var url = require('url');
@@ -42,6 +43,7 @@ function createRequest(options) {
mockRequest.method = (options.method) ? options.method : 'GET';
mockRequest.url = (options.url) ? options.url : '';
+ mockRequest.originalUrl = options.originalUrl || mockRequest.url;
mockRequest.path = (options.url) ? url.parse(options.url).pathname : '';
mockRequest.params = (options.params) ? options.params : {};
mockRequest.session = (options.session) ? options.session : {};
@@ -187,6 +189,23 @@ function createRequest(options) {
};
/**
+ * Function: _setOriginalUrl
+ *
+ * Sets the URL value that the client gets when the called the 'originalUrl'
+ * property.
+ *
+ * Parameters:
+ *
+ * url - The request path, e.g. /my-route/452
+ *
+ * Note: We don't validate the string. We just return it. Typically, these
+ * do not include hostname, port or that part of the URL.
+ */
+ mockRequest._setOriginalUrl = function(url) {
+ mockRequest.originalUrl = url;
+ };
+
+ /**
* Function: _setBody
*
* Sets the body that the client gets when the called the 'body'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git
More information about the Pkg-javascript-commits
mailing list