Skip to content

Commit

Permalink
improvement to query string parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Nov 27, 2013
1 parent 69bf9b5 commit b314cf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module.exports = function(grunt) {
globals: {
head: false,
module: false,
console: false
console: false,
unescape: false
}
},
files: [ 'Gruntfile.js', 'js/reveal.js' ]
Expand Down
7 changes: 5 additions & 2 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3300,17 +3300,20 @@ var Reveal = (function(){
getQueryHash: function() {
var query = {};

location.search.replace( /[A-Z0-9]+?=(\w*)/gi, function(a) {
location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, function(a) {
query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
} );

// Basic deserialization
for( var i in query ) {
var value = query[ i ];

query[ i ] = unescape( value );

if( value === 'null' ) query[ i ] = null;
else if( value === 'true' ) query[ i ] = true;
else if( value === 'false' ) query[ i ] = false;
else if( !isNaN( parseFloat( value ) ) ) query[ i ] = parseFloat( value );
else if( value.match( /^\d+$/ ) ) query[ i ] = parseFloat( value );
}

return query;
Expand Down
Loading

0 comments on commit b314cf7

Please sign in to comment.