Handle params array in Drupal.Views.parseQueryString JS function

Created on 17 January 2014, almost 11 years ago
Updated 22 February 2023, almost 2 years ago

There're 2 problems of the original function:
1. Do not handle params array
2. Do not remove #hash

Original:

Object {a: "test1", b: "test2", topics[]: "cba#hash"}

Patched:

Object {a: "test1", b: "test2", topics[]: Array[2]}
a: "test1"
b: "test2"
topics[]: Array[2]
0: "abc"
1: "cba"

Patched code will be same as PHP:

$url = 'www.example.com/path?&a=test1&b=test2&topics[]=abc&topics[]=cba#hash';
$parts = parse_url($url);
parse_str($parts['query'], $query);
var_dump($query);

array(3) {
  ["a"]=>
  string(5) "test1"
  ["b"]=>
  string(5) "test2"
  ["topics"]=>
  array(2) {
    [0]=>
    string(3) "abc"
    [1]=>
    string(3) "cba"
  }
}
πŸ› Bug report
Status

Closed: won't fix

Version

9.5

Component
ViewsΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡­πŸ‡°Hong Kong droplet

Live updates comments and jobs are added and updated live.
  • Needs documentation

    A documentation change is requested elsewhere. For Drupal core (and possibly other projects), once the change has been committed, this status should be recorded in a change record node.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Is this still relevant?

    Can we just use UrlSearchParams now?

  • Status changed to Closed: won't fix almost 2 years ago
  • πŸ‡«πŸ‡·France nod_ Lille

    We can use it to simplify the code but URLSearchParam wouldn't give an array topics, at best it gives an array for topics[] using the getAll method. Close enough though.

    Given the age of the issue, the lack of activity and the fact that URLSearchParam is a thing. It does't seem like the fix is necessary and modern alternative makes it easier to work with url search params than using this method.

Production build 0.71.5 2024