It looks like it is a bit more specific.
This function seems to be very specific to DEBUG=1/Firefox nightly support,
where we hack app://*.gaiamobile.org into http://*.gaiamobile.org.
https://bugzilla.mozilla.org/show_bug.cgi?id=957418#c22
It could be worth commenting about that.