Search code examples
urlfirefox-addon-sdk

Convert SDK's url to nsIURI


Is there a proper way to convert a nsIURL to an Addon url?

They share many properties, but differ in some (f.ex. the addon url has a.hash property where nsIURL has ref).

Is it recommended to simply use the property (duck typing) with a failover (f.ex. url.hash || url.ref) or is there a simple way to convert between these?


Solution

  • This proved to be hard to do, as the types are neither compatible not always complete.

    As a workaround, use the uri.spec string internally, and only convert when needed for some methods.