Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow slashes delimited as sugar for arrays

  • Loading branch information...
commit 23262be2b5b82b17306daf5632eca9d4819e08d9 1 parent cb1bafa
@kriszyp kriszyp authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/parser.js
View
10 lib/parser.js
@@ -43,9 +43,15 @@ function parse(/*String|Object*/query, parameters){
if(exports.jsonQueryCompatible){
query = query.replace(/%3C=/g,"=le=").replace(/%3E=/g,"=ge=").replace(/%3C/g,"=lt=").replace(/%3E/g,"=gt=");
}
+ if(query.indexOf("/") > -1){ // performance guard
+ // convert slash delimited text to arrays
+ query = query.replace(/[\+\*\$\-:\w%\._]*\/[\+\*\$\-:\w%\._\/]*/g, function(slashed){
+ return "(" + slashed.replace(/\//g, ",") + ")";
+ });
+ }
// convert FIQL to normalized call syntax form
- query = query.replace(/([\+\*\-:\w%\._]+)([<>!]?=(?:[\w]*=)?|>|<)(\([\+\*\$\-:\w%\._,]+\)|[\+\*\$\-:\w%\._]*|)/g,
- //<--- property ---><------ operator -----><---------------- value ------------------>
+ query = query.replace(/(\([\+\*\$\-:\w%\._,]+\)|[\+\*\$\-:\w%\._]*|)([<>!]?=(?:[\w]*=)?|>|<)(\([\+\*\$\-:\w%\._,]+\)|[\+\*\$\-:\w%\._]*|)/g,
+ //<--------- property -----------><------ operator -----><---------------- value ------------------>
function(t, property, operator, value){
if(operator.length < 3){
if(!operatorMap[operator]){
Please sign in to comment.
Something went wrong with that request. Please try again.