query-path
Advanced tools
Comparing version 1.0.2 to 1.0.3
42
index.js
'use strict'; | ||
exports.qsval = function(name, url) { | ||
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | ||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); | ||
var _ = require('lodash'); | ||
exports.queryStringByKey = function(key, url) { | ||
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | ||
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)"); | ||
if (url) { | ||
@@ -12,1 +13,36 @@ var results = regex.exec(url); | ||
} | ||
exports.pathByIndex = function(index, url) { | ||
var pathname = ''; | ||
var retVal = ''; | ||
if (url) { | ||
pathname = url; | ||
} else { | ||
pathname = window.location.pathname; | ||
} | ||
pathname = _.compact(pathname.split('/')); | ||
if (index < pathname.length) { | ||
retVal = pathname[index]; | ||
} | ||
return retVal; | ||
} | ||
exports.pathByMatchingString = function(matchingString, url) { | ||
var pathname = ''; | ||
var retVal = []; | ||
if (url) { | ||
pathname = url; | ||
} else { | ||
pathname = window.location.pathname; | ||
} | ||
pathname = _.compact(pathname.split('/')); | ||
if (matchingString && !_.isEmpty(pathname) { | ||
_.each(pathname, function(val, i) { | ||
if (val.indexOf(matchingString) >= 0) { | ||
retVal.push[val]; | ||
} | ||
}); | ||
} | ||
return retVal; | ||
} |
{ | ||
"name": "query-path", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "helper methods to work with URL query string and pathname", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
1916
44