persvr / rql

Resource Query Language
http://www.persvr.org/
267 stars 49 forks source link

string passed to converter is trunkated by next ':' #30

Closed xhronos closed 10 years ago

xhronos commented 11 years ago

Passing the following string to the parser

string:2013-06-06T10:53:59.763Z

results in

2013-06-06T10

being passed to the converter since the colon is used as delimiter.

xhronos commented 11 years ago

This fix for stringToValue() in parser.js seems to work:


function stringToValue(string, parameters){
    var converter = exports.converters['default'];
    if(string.charAt(0) === "$"){
        var param_index = parseInt(string.substring(1)) - 1;
        return param_index >= 0 && parameters ? parameters[param_index] : undefined;
    }
    var parts = /^(\w+):(.*)$/.exec(string);                     //::::
    if (parts && parts[1]) {                                     //::::
        converter = exports.converters[parts[1]];                //::::
        if(!converter){
            throw new URIError("Unknown converter " + parts[1]); //::::
        }
        string = parts[2];                                       //::::
    }
    return converter(string);
};