https://bugzilla.wikimedia.org/show_bug.cgi?id=30712
Krinkle <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Krinkle <[email protected]> 2011-09-08 00:58:51 UTC --- (In reply to comment #1) > (In reply to comment #0) > > I would like to understand this issue a bit more. Where exactly would problems > arise? Michael Dale was describing an issue where he passed a url from an API (or other foreign source, perhaps element.src/.href) to new mw.Url() and it turned out to throw an exception. > > > * Change the loose/strict parse regex to accept procol-relative urls > > Makes sense to me Cool. I originally thought of using wgUrlProtocols to create the regex but that may not be a good idea, as that 1) limits us to protocols mediawiki allows, which doesn't always make sense, 2) makes the lib dependant on having wgUrlProtocols, which makes it not usable for third parties or out of a mw-index.php context. > > > * Add a static method: mw.Uri.expandUrl (which adds protocol (if not > > present) > > and perhaps wgServer as well if needed) Like I said "one or more of the following". Some make other suggestions redundant. The thought behind this was in case you thought PR shouldn't go into the regex: var loc = new mw.Uri ( mw.Uri.expand( input ) ); Note that that might still be handy for relative _path_'s (like expanding "/w/Foo:Bar" with the server to become a complete url (which may or may not be PR ) > But since this runs in the browser only, we always know the protocol and > authority anyway. So why would we ever want a protocol-relative URL at that > point? > > So would this be okay? > > # within https://sample.com/ > > var url = new mw.Uri( 'http://sample.com/foo/bar' ); > console.log( url ) // prints "http://sample.com/foo/bar" > > var PRurl = new mw.Uri( '//foo/bar' ); > console.log( PRurl ) // prints "https://sample.com/foo/bar" I'm not sure that makes sense. I can imagine some html5 funky cross-domain situations where we'd want to preserve the protocol (or absence thereof). Besides //sample.com works pretty much everywhere as is, especially in the front-end. > > * Add prototype function that returns true/false depending on whether the > > protocol is in wgUrlProtocols > > Why not do it like this? > > $.inArray( wgUrlProtocols, url.protocol ) Well, it'd be more like $.inArray( mw.config.get( 'urlProtocols' ), new mw.Uri( input ).protocol ) !== -1 But still, it doesn't need a function in mw.Uri, it's fine :) -- 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 [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
