getQuery.js 451 B

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