Login Register

dojo.uri changes

dojo.uri's functionality has been absorbed into the resource loader. The functionality mentioned below is always available as part of the base dojo.js in 0.9.

  • The dojo.uri.Uri() constructor has been made private at dojo._Uri(). This constructor may be removed or heavily altered for the final 0.9 release. Do not count on being able to use it.
  • dojo.uri.dojoUri() has been removed. Concatenate your url fragment with dojo.baseUrl to get the same result. You should use dojo.moduleUrl() whenever possible, and only use dojo.baseUrl + urlPath if you are referencing a path that is not part of a module.
  • dojo.uri.moduleUri() has moved to dojo.moduleUrl().

Replacement for parsing URIs?

I use dojo.uri.Uri not so much to get a URI relative to the Dojo root but rather as a nice utility for parsing URIs and then working with the constituent parts (e.g. query, fragment, etc.)

Will there be any replacement for this URI parsing functionality if dojo.uri.Uri goes away?

It is available right now as

It is available right now as a "private" constructor: dojo._Url. It is private because it was not clear if it was needed inside of dojo base or if the functionality should be moved to a separate module in Dojo core. So, use it if you want, but be aware it may be moved out somewhere else later under a different name.

+1 to making this a public constructor

IMHO, given how central URLs are to the web it seems natural to me that this would be public, even in the core namespace (that is, dojo.Url instead of dojo._Url).

I've filed a bug (http://trac.dojotoolkit.org/ticket/5548) to try to get this into the next version of Dojo, or at least get an up-or-down decision :)

I'm happy as long as the functionality exists somewhere

Thanks James, my real concern is that this functionality exist somewhere in Dojo, whether in base or not. I just want to have a Dojo function I can point people at when they want to manipulate URIs, and don't want to reinvent my own when the Dojo one works great.

Thanks for the response.

Is it time?

I just found myself using dojo._Uri for the first time in a while and was wondering if it is finally time in Dojo 1.2 to make it or something similar supported API :-)

Another thought

Another idea would be to factor out the 'relative to Dojo' concerns from the functionality and just have a dojo.parseURI function that returns an object similar to window.location for some URI-ish string.

Just a thought.

experimental code:

dojo.provide("dojox.util.url");
dojo.experimental("dojox.util.url");
// Summary: class for experimental URL utilities
//     
dojox.util.url.registerGlobals = function() {
        // summary: parses and returns key/var pairs passed as a query string.
        // description:
        var str = {};
        console.debug(location);
        var parts = location.search.split(/&/);
        dojo.forEach(parts,function(pair) {
                var tmp = pair.match(/([a-zA-Z0-9]*)=(.*)/);
                if (tmp) { str[tmp[1]] = tmp[2]; }
        },this);
        return str; // Object
}
// uncomment to enable bootload parsing?
// dojo.addOnLoad(dojoc.util.url.parseQuery);
dojox.util.url.getHash = function() {
        // summary: return the value of a url's hash
        // checking to see if ALL browsers love this   
        return location.hash || false;
}
... it's a start. :P

dojo.queryToObject(location.h

dojo.queryToObject(location.href.split("?")[1]); is similar to the registerGlobals function.