Search code examples
urlurl-encodingurldecode

Does URL querystring encoding preserve order for multi-valued keys?


http://www.example.com?a=1&a=2 has a valid form-urlencoded querystring and has two values (1 and 2) for the key a.

  1. Is there any spec or standard for URL consumers guaranteeing ordering (or lack thereof) of parsed values?
  2. Do common implementations (Django's QueryDict, dojo's queryToObject, PHP, etc) preserve ordering?

Solution

  • OK, this question: Authoritative position of duplicate HTTP GET query keys, suggests there is no such standard and that order should not be considered reliable.

    My experience has been that latest WebKit encodes identically named form fields in DOM order and that Django's QueryDict preserves that order. Shaky ground at best.