From bf8e42f1571b3391a586be9e118a39c011615b60 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 1 Nov 2013 09:21:49 -0400 Subject: [PATCH] Add origin property --- index.js | 1 + test/tests.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/index.js b/index.js index a4c8e03..3295333 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ exports.parse = function(url){ hash: a.hash, hostname: a.hostname || location.hostname, pathname: a.pathname.charAt(0) != '/' ? '/' + a.pathname : a.pathname, + origin: a.origin, protocol: !a.protocol || ':' == a.protocol ? location.protocol : a.protocol, search: a.search, query: a.search.slice(1) diff --git a/test/tests.js b/test/tests.js index 3566bfe..1a327f3 100644 --- a/test/tests.js +++ b/test/tests.js @@ -96,6 +96,11 @@ describe('url.parse(str)', function(){ assert('google.com:3000' == url.host); }) + it('should support .origin', function(){ + var url = parse('http://google.com:3000/foo/bar'); + assert('http://google.com:3000' == url.origin); + }) + it('should support .search', function(){ var url = parse('http://google.com:3000/foo/bar?name=tobi'); assert('?name=tobi' == url.search);