Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: Jan 22, 2018 11:25 PM
Views: 20
Tags: array conver url
  1. function URLToArray(url) {
  2.     var request = {};
  3.     var pairs = url.substring(url.indexOf('?') + 1).split('&');
  4.     for (var i = 0; i < pairs.length; i++) {
  5.         if(!pairs[i])
  6.             continue;
  7.         var pair = pairs[i].split('=');
  8.         request[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  9.      }
  10.      return request;
  11. }