https://bugzilla.wikimedia.org/show_bug.cgi?id=27730

Krinkle <krinklem...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |krinklem...@gmail.com
            Summary|Create enhanced version of  |Add JS utility function to
                   |mw.util.getParamValue to    |get all parameter values
                   |get an object with all      |(like
                   |parameters (in one only     |mw.util.getParamValue) in
                   |call)                       |one call

--- Comment #4 from Krinkle <krinklem...@gmail.com> 2011-03-08 08:18:20 UTC ---
In one of the development ideas for mw.util was a getAllParams.

One of weak spots it fixed was duplicate values and problems with the #-tag.
I'll commit this tonight, not sure why it wasn't added until now.

Using string split does not seem a solid approach to me though. Consider the
following:

/path.to?key=value&key=bettervalue&foo=bar#!testingfoo&some&key=1

The values need to be the same as for mw.util.getParamValue:

<pre>
parseUrlParams: function( url ) {
        url = url ? url : document.location.href;
        var match = url.match(/\?[^#]*/);
        if (match === null) {
            return null;
        }
        var query = match[0];
        var ret = {};
        var pattern = /[&?]([^&=]*)=?([^&]*)/g;
        match = pattern.exec(query);
        for (; match !== null; match = pattern.exec(query)) {
            var key = decodeURIComponent(match[1]);
            var value = decodeURIComponent(match[2]);
            ret[key] = value;
        }
        return ret;
}
</pre>

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to