HierarchicalURI.st
changeset 1268 48b43aebf125
parent 1267 5e7f102e094d
child 1271 ca2e206e7c7f
--- a/HierarchicalURI.st	Thu Jul 10 16:33:01 2003 +0200
+++ b/HierarchicalURI.st	Fri Jul 11 14:48:15 2003 +0200
@@ -271,7 +271,7 @@
     |i i1 separator|
 
     (aString startsWith:'//') ifTrue:[
-        i := aString indexOfAny:'~/?#' startingAt:3.
+        i := aString indexOfAny:'/?#' startingAt:3.
         i == 0 ifTrue:[
             authority := aString copyFrom:3.
             ^ self.
@@ -288,15 +288,6 @@
         ]
     ].
 
-    isAbsolute ifFalse:[
-        i ~~ 0 ifTrue:[
-            (aString at:i) == $~ ifTrue:[
-                pathSegments add:'~'.
-                i := i + 1
-            ].
-        ].
-    ].
-
     [
         i1 := aString indexOfAny:'/?#' startingAt:i+1.
         i1 == 0 ifTrue:[ |path|
@@ -314,14 +305,11 @@
             pathSegments add:(aString copyFrom:i+1 to:i1-1).
             isAbsolute ifTrue:[
                 pathSegments size == 1 ifTrue:[
-                    pathSegments first = '~' ifTrue:[
+                    (pathSegments first startsWith:$~) ifTrue:[
                         isAbsolute := false
                     ].
                 ].
             ].
-            (pathSegments size == 1 and:[pathSegments first = '~']) ifTrue:[
-
-            ].
             i := i1.
         ].
     ] doWhile:[separator == $/].
@@ -361,6 +349,29 @@
 
 !HierarchicalURI methodsFor:'printing & storing'!
 
+directoryPath
+    "answer the directory path part of the URI"
+
+    |aStream|
+
+    aStream := WriteStream on:''.
+
+    pathSegments size ~~ 0 ifTrue: [
+        self isAbsolute ifTrue:[
+            aStream nextPut:$/.
+        ].
+        pathSegments size > 1 ifTrue:[
+            (pathSegments copyFrom:2) do:[:p|
+                self class escape:p allow:'~;:@&=+",' on:aStream
+            ] separatedBy:[
+                aStream nextPut:$/
+            ].
+        ].
+    ].
+
+    ^ aStream contents
+!
+
 path
     "answer the path part of the URI"
 
@@ -369,11 +380,11 @@
     aStream := WriteStream on:''.
 
     pathSegments size ~~ 0 ifTrue: [
-        isAbsolute ifTrue:[
+        self isAbsolute ifTrue:[
             aStream nextPut:$/.
         ].
         pathSegments do:[:p|
-            self class escape:p allow:';:@&=+",' on:aStream
+            self class escape:p allow:'~;:@&=+",' on:aStream
         ] separatedBy:[
             aStream nextPut:$/
         ].
@@ -403,18 +414,18 @@
     authority notNil ifTrue: [
         aStream nextPutAll:'//'.
         doEscape ifTrue:[
-            self class escape:authority allow:'$,;:@&=+' on:aStream
+            self class escape:authority allow:'~$,;:@&=+' on:aStream
         ] ifFalse:[
             aStream nextPutAll:authority
         ]
     ].
     pathSegments size ~~ 0 ifTrue: [
-        isAbsolute ifTrue:[
+        self isAbsolute ifTrue:[
             aStream nextPut:$/.
         ].
         pathSegments do:[:p|
             doEscape ifTrue:[
-                self class escape:p allow:';:@&=+",' on:aStream
+                self class escape:p allow:'~;:@&=+",' on:aStream
             ] ifFalse:[
                 aStream nextPutAll:p
             ]
@@ -466,5 +477,5 @@
 !HierarchicalURI class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/HierarchicalURI.st,v 1.4 2003-07-10 14:33:01 tm Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/HierarchicalURI.st,v 1.5 2003-07-11 12:47:04 stefan Exp $'
 ! !