KUrl behavior.
Leonardo Stern
leonardo.stern at gmail.com
Wed Dec 20 01:54:27 CET 2006
In kdecore/kurl.h , I found the following statement :
* The constructor KUrl(const QString&) expects a string properly escaped,
* or at least non-ambiguous.
* If you have the absolute path you should use KUrl::fromPath(const QString&).
* \code
* KUrl kurl = KUrl::fromPath("/bar/#foo#");
* QString url = kurl.url(); // -> "file:///bar/%23foo%23"
* \endcode
*
* If you have the URL of a local file or directory and need the absolute path,
* you would use path().
* \code
* KUrl url( "file:///bar/%23foo%23" );
* ...
* if ( url.isLocalFile() )
* QString path = url.path(); // -> "/bar/#foo#"
* \endcode
So if I have KUrl kurl(""file:///home/dfaure/my#%2f""), I should expect :
kurl.url() == "file:///home/dfaure/my%23%2f"
kurl.path() == "file:///home/dfaure/my#/" ?
In "kdecore/tests/kurltest.cpp" I found the following testcase (line 228):
/* KUrl url1; QString u1 */
u1 = "file:///home/dfaure/my#%2f";
url1 = u1;
// KDE3: was %2f, but this is OK too
QCOMPARE( url1.url(), QString("file:///home/dfaure/my#/") );
but url1.url() returns "file:///home/dfaure/my%23/"
I would expect "file:///home/dfaure/my%23%2f" as described in kurl.h
instead of "file:///home/dfaure/my#/" or "file:///home/dfaure/my%23/".
I'm missing something ?
regards,
Leonardo Stern
More information about the Kde-windows
mailing list