combo-url-parser
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -1,1 +0,3 @@ | ||
module.exports = require('./lib/parser.js'); | ||
var parser = module.exports = require('./lib/parser.js'); | ||
parser.middleware = require('./lib/middleware'); |
@@ -0,31 +1,36 @@ | ||
var URL = require("url"); | ||
function join(a, b) { | ||
if (a && b) { | ||
a = a.replace(/\/?$/, '/'); | ||
b = b.replace(/^\/?/, ''); | ||
} | ||
return a + b; | ||
} | ||
module.exports = function(url){ | ||
var base = '', | ||
paths = [], | ||
parts, | ||
idx1, | ||
originurl = url, | ||
idx2; | ||
var lead = '??'; | ||
var sep = ','; | ||
//remove the query | ||
idx1 = url.indexOf('??'); | ||
idx2 = url.indexOf('?'); | ||
//get real query | ||
if (idx1 > -1 && (idx1 <= idx2)) { | ||
base = url.substring(0, idx1); | ||
url = url.substring(idx1 + 2); | ||
idx2 = url.indexOf('?'); | ||
var idx1 = url.indexOf(lead); | ||
if (idx1 === -1) { | ||
return [url]; | ||
} | ||
var base = url.substring(0, idx1); | ||
var ext = URL.parse(url.substring(idx1 + lead.length)); | ||
return ext.pathname.split(sep).map(function(subPath){ | ||
if (idx2 > -1) { | ||
url = url.substring(0, idx2); | ||
} | ||
paths = url.split(','); | ||
paths = paths.map(function(val){ | ||
var path = base + '/' + val; | ||
return path.replace(/\/+/g, '/'); | ||
return URL.format({ | ||
search: ext.search, | ||
pathname: join(base, subPath) | ||
}); | ||
}); | ||
return paths; | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "A util to parser comboed url", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"repository": { | ||
@@ -12,3 +12,3 @@ "type": "git", | ||
"scripts": { | ||
"test": "jasmine-node ." | ||
"test": "./node_modules/.bin/mocha" | ||
}, | ||
@@ -18,4 +18,9 @@ "engines": { | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
"dependencies": { | ||
"combined-stream": "0.0.4", | ||
"request": "~2.34.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.18.0" | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
[![build status](https://secure.travis-ci.org/maxbbn/combo-url-parser.png)](http://travis-ci.org/maxbbn/combo-url-parser) | ||
util to parse comboed url; | ||
@@ -2,0 +3,0 @@ |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
4112
8
87
24
0
2
1
+ Addedcombined-stream@0.0.4
+ Addedrequest@~2.34.0
+ Addedasn1@0.1.11(transitive)
+ Addedassert-plus@0.1.5(transitive)
+ Addedasync@0.9.2(transitive)
+ Addedaws-sign2@0.5.0(transitive)
+ Addedboom@0.4.2(transitive)
+ Addedcombined-stream@0.0.4(transitive)
+ Addedcryptiles@0.2.2(transitive)
+ Addedctype@0.5.3(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedforever-agent@0.5.2(transitive)
+ Addedform-data@0.1.4(transitive)
+ Addedhawk@1.0.0(transitive)
+ Addedhoek@0.9.1(transitive)
+ Addedhttp-signature@0.10.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedmime@1.2.11(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.3.0(transitive)
+ Addedqs@0.6.6(transitive)
+ Addedrequest@2.34.0(transitive)
+ Addedsntp@0.2.4(transitive)
+ Addedtldts@6.1.72(transitive)
+ Addedtldts-core@6.1.72(transitive)
+ Addedtough-cookie@5.1.0(transitive)
+ Addedtunnel-agent@0.3.0(transitive)