Code coverage report for queryString/getQuery.js

Statements: 100% (7 / 7)      Branches: 50% (1 / 2)      Functions: 100% (3 / 3)      Lines: 100% (6 / 6)     

All files » queryString/ » getQuery.js
1 2 3 4 5 6 7 8 9 10 11 12 13 141         1 28 28 28     1    
define(function () {
 
    /**
     * Gets full query as string with all special chars decoded.
     */
    function getQuery(url) {
        url = url.replace(/#.*/, ''); //removes hash (to avoid getting hash query)
        var queryString = /\?[a-zA-Z0-9\=\&\%\$\-\_\.\+\!\*\'\(\)\,]+/.exec(url); //valid chars according to: http://www.ietf.org/rfc/rfc1738.txt
        return (queryString)? decodeURIComponent(queryString[0]) : '';
    }
 
    return getQuery;
});