[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: PATCH: kurl and urls like "file:a"
From: David Smith <dsmith () algonet ! se>
Date: 2001-06-19 20:13:55
[Download RAW message or body]
I have tried to use KURL with short relative urls like "file:a" and
"file:a/". I think that fileName() and directory() give the wrong
result for those urls.
While urls like "file:a" are probably incorrect according to RFCs, the
way it is now is inconsistent, so it would be good to change it in any
case. With the appended patch, the results are like I've indicated
below I think they should be:
{david} ~/CVS-HEAD/CVS$ ./kurl_test 'file:a'
url: 'file:a'
fileName(false): 'a'
fileName(true): 'a'
directory(false,false): 'a' <-- should be empty
directory(true,false): 'a' <-- -- " --
directory(true,true): 'a' <-- -- " --
{david} ~/CVS-HEAD/CVS$ ./kurl_test 'file:a/'
url: 'file:a/'
fileName(false): '(null)'
fileName(true): '(null)' <-- should be 'a'
directory(false,false): 'a/'
directory(true,false): 'a'
directory(true,true): 'a' <-- should be empty
So, is the patch any good? :)
/David
Index: kurl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kurl.cpp,v
retrieving revision 1.166
diff -u -r1.166 kurl.cpp
--- kurl.cpp 2001/03/30 16:17:41 1.166
+++ kurl.cpp 2001/06/19 19:46:16
@@ -1209,14 +1209,19 @@
return fname;
// Does the path only consist of '/' characters ?
- if ( len == 1 && m_strPath[ 1 ] == '/' )
+ if ( len == 1 && m_strPath[ 0 ] == '/' )
return fname;
int i = m_strPath.findRev( '/', len - 1 );
// If ( i == -1 ) => the first character is not a '/'
// So it's some URL like file:blah.tgz, return the whole path
- if ( i == -1 )
- return m_strPath;
+ if ( i == -1 ) {
+ if ( len == m_strPath.length() )
+ return m_strPath;
+ else
+ // Might get here if _strip_trailing_slash is true
+ return m_strPath.left( len );
+ }
fname = m_strPath.mid( i + 1, len - i - 1 ); // TO CHECK
// fname.assign( m_strPath, i + 1, len - i - 1 );
@@ -1264,8 +1269,10 @@
return result;
int i = result.findRev( "/" );
+ // If ( i == -1 ) => the first character is not a '/'
+ // So it's some URL like file:blah.tgz, with no path
if ( i == -1 )
- return result;
+ return QString::null;
if ( i == 0 )
{
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic