Skip to content

Instantly share code, notes, and snippets.

View omidgfx's full-sized avatar
💭
I may be slow to respond.

Pejman Chatrrouz omidgfx

💭
I may be slow to respond.
View GitHub Profile
@tobsn
tobsn / url.query.js
Created September 14, 2012 03:29
node.js parse array form from query string into array like php does
url.query = function( url ) {
var parsed = this.parse( url, true, false ),
query = Object.keys( parsed.query ),
result = {};
if( query.length > 0 ) {
query.forEach(function(key){
if( key.match( /([^\[]+)\[([^\]]+)\]/g ) ) {
key.replace( /([^\[]+)\[([^\]]+)\]/g, function( $0, $1, $2 ) {
result[$1] = result[$1] || {};
result[$1][$2] = parsed.query[key];