query-path
Advanced tools
Comparing version 1.0.7 to 1.0.8
32
index.js
'use strict'; | ||
var _ = require('lodash'); | ||
var compact = function(array) { | ||
var index = -1, | ||
length = array ? array.length : 0, | ||
resIndex = -1, | ||
result = []; | ||
while (++index < length) { | ||
var value = array[index]; | ||
if (value) { | ||
result[++resIndex] = value; | ||
} | ||
} | ||
return result; | ||
} | ||
exports.queryStringByKey = function(key, url) { | ||
@@ -20,5 +35,5 @@ key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | ||
} else { | ||
pathname = (typeof window !== "undefined")?window.location.pathname:''; | ||
pathname = (typeof window !== "undefined") ? window.location.pathname : ''; | ||
} | ||
pathname = _.compact(pathname.split('/')); | ||
pathname = compact(pathname.split('/')); | ||
if (index < pathname.length) { | ||
@@ -36,11 +51,12 @@ retVal = pathname[index]; | ||
} else { | ||
pathname = (typeof window !== "undefined")?window.location.pathname:''; | ||
pathname = (typeof window !== "undefined") ? window.location.pathname : ''; | ||
} | ||
pathname = _.compact(pathname.split('/')); | ||
if (matchingString && !_.isEmpty(pathname)) { | ||
_.each(pathname, function(val, i) { | ||
pathname = compact(pathname.split('/')); | ||
console.info('pathname', pathname); | ||
if (matchingString && pathname.length > 0) { | ||
pathname.map(function(val, i) { | ||
if (val.indexOf(matchingString) >= 0) { | ||
retVal.push(val); | ||
} | ||
}); | ||
}) | ||
} | ||
@@ -47,0 +63,0 @@ |
{ | ||
"name": "query-path", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "helper methods to work with URL query string and pathname", | ||
@@ -30,5 +30,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"lodash": "^3.10.1" | ||
}, | ||
"devDependencies": {} | ||
} |
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
3331
0
57
- Removedlodash@^3.10.1
- Removedlodash@3.10.1(transitive)