ZnUrl and closePath
I'm not sure the behaviour of ZnUrl>>#closePath is the desired one. 'http://foo/a/b/c/' asZnUrl closePath gives http://foo/a/b/c// <http://foo/a/b/c//> It adds a slash if the #isSlash returns false. #isSlash indicated only the server root and not (what I was thinking) it returns true on trailing slash. IMHO #isSlash should be a test for trailing slash and #isRootPath should be a test for a non-existing or / path. Norbert
Norbert,
On 29 Apr 2015, at 13:07, Norbert Hartl <norbert@hartl.name> wrote:
I'm not sure the behaviour of ZnUrl>>#closePath is the desired one.
'http://foo/a/b/c/' asZnUrl closePath
gives
It adds a slash if the #isSlash returns false. #isSlash indicated only the server root and not (what I was thinking) it returns true on trailing slash. IMHO #isSlash should be a test for trailing slash and #isRootPath should be a test for a non-existing or / path.
Norbert
#isSlash was/is intended to be what it is, but indeed #closePath could maybe be improved. What about closePath self isDirectoryPath ifFalse: [ self addPathSegment: #/ ] ? Would that work for your use case ? Sven
Am 29.04.2015 um 13:53 schrieb Sven Van Caekenberghe <sven@stfx.eu>:
Norbert,
On 29 Apr 2015, at 13:07, Norbert Hartl <norbert@hartl.name> wrote:
I'm not sure the behaviour of ZnUrl>>#closePath is the desired one.
'http://foo/a/b/c/' asZnUrl closePath
gives
It adds a slash if the #isSlash returns false. #isSlash indicated only the server root and not (what I was thinking) it returns true on trailing slash. IMHO #isSlash should be a test for trailing slash and #isRootPath should be a test for a non-existing or / path.
Norbert
#isSlash was/is intended to be what it is, but indeed #closePath could maybe be improved.
What about
closePath self isDirectoryPath ifFalse: [ self addPathSegment: #/ ]
?
Would that work for your use case ?
Sure. Didn't know about isDirectoryPath. Norbert
=== Name: Zinc-Resource-Meta-Core-SvenVanCaekenberghe.52 Author: SvenVanCaekenberghe Time: 29 April 2015, 2:50:03.993582 pm UUID: b8c7646e-74ff-4200-aa7f-4fdcd1d13dd2 Ancestors: Zinc-Resource-Meta-Core-SvenVanCaekenberghe.51 Modify ZnUrl>>#closePath to only add a / if there is no trailing one already (Thx Norbert Hartl) ===
On 29 Apr 2015, at 14:27, Norbert Hartl <norbert@hartl.name> wrote:
Am 29.04.2015 um 13:53 schrieb Sven Van Caekenberghe <sven@stfx.eu>:
Norbert,
On 29 Apr 2015, at 13:07, Norbert Hartl <norbert@hartl.name> wrote:
I'm not sure the behaviour of ZnUrl>>#closePath is the desired one.
'http://foo/a/b/c/' asZnUrl closePath
gives
It adds a slash if the #isSlash returns false. #isSlash indicated only the server root and not (what I was thinking) it returns true on trailing slash. IMHO #isSlash should be a test for trailing slash and #isRootPath should be a test for a non-existing or / path.
Norbert
#isSlash was/is intended to be what it is, but indeed #closePath could maybe be improved.
What about
closePath self isDirectoryPath ifFalse: [ self addPathSegment: #/ ]
?
Would that work for your use case ?
Sure. Didn't know about isDirectoryPath.
Norbert
participants (2)
-
Norbert Hartl -
Sven Van Caekenberghe