tiny-parse
Advanced tools
Comparing version 1.0.1 to 1.0.2
"use strict"; | ||
const coerce = require("tiny-coerce"), | ||
url = require("url"); | ||
url = require("url"), | ||
space = /\s+/; | ||
@@ -67,4 +68,21 @@ function trim (obj) { | ||
function parse (uri) { | ||
let luri = uri, | ||
function uri (req) { | ||
let header = req.headers.authorization || "", | ||
auth = "", | ||
token; | ||
if (!isEmpty(header)) { | ||
token = header.split(space).pop() || ""; | ||
auth = new Buffer(token, "base64").toString(); | ||
if (!isEmpty(auth)) { | ||
auth += "@"; | ||
} | ||
} | ||
return "http://" + auth + req.headers.host + req.url; | ||
} | ||
function parse (arg) { | ||
let luri = arg.url ? uri(arg) : arg, | ||
idxAscii, idxQ, parsed; | ||
@@ -71,0 +89,0 @@ |
{ | ||
"name": "tiny-parse", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "URL parsing with coercion of `query`", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,4 +17,8 @@ # tiny-parse | ||
### API | ||
*parse()* | ||
Parses the input, accepts a URL or `http.ClientRequest` | ||
## License | ||
Copyright (c) 2016 Jason Mulligan | ||
Licensed under the BSD-3 license. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5370
100
24