On Friday, 19 de August de 2011 00:11:21 [email protected] wrote: > Are there use cases where you need to accept all sorts of URLs (absolute > and relative) as well as local file paths (again, relative or absolute)?
As David said, such a case would be ambiguous. > I can see a media player (or some other content browser/viewer) that > wants to handle URLs and local files transparently, without forcing the > user to use "file://" prefixes. But I don't see what it would do with a > relative URL. That's the only case I can think of: the Location field in a browser or similar application -- that is, parsing user input. But we have QUrl::fromUserInput for that, which has completely different semantics. > So, I see this not so much as Strict vs Tolerant parsing, but a very > specific type of parsing geared towards user input that is either an > absolute URL or a file path (we may still want to allow relative paths, > here). > > QUrl url(fileOrUrl, QUrl::UserInput); > if (url.isFilePath()) > doSomethingDifferent(); > > QUrl can then quickly determine which one it is and process the string > accordingly. QUrl::fromUserInput already exists. In addition to dealing with local paths, it will also convert "example.com" to "http://example.com", as well as "ftp.example.com/pub/linux" to "ftp://example.com/pub/linux". QUrl::fromUserInput is also guaranteed (or should be, if it isn't) to do exactly the same as the normal constructor if a full URL with scheme is passed, except for one-letter schemes, which are likely to be Windows/Symbian file paths. This way, QUrl::fromUserInput can be used to handle command-line arguments, which may be entered by the user as well as by another application. > In other use cases (say, when picking a[href] from a webpage), I would > prefer that relative URLs are not implicitly parsed or used as local > file paths. > > Explicit is better than implicit. -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel Open Source Technology Center PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
