Skip to content

Is asZnUrl implemented correctly for FileReferences? #99

@kasperosterbye

Description

@kasperosterbye

@Ducasse and I ran into a peculiar error today, not sure if the problem is mine or yours :-)

The situation an absolute path, for example '/Users/kasper/tmp'.
Assuming the directory tmp exist, I get '/Users/kasper/tmp' asFileReference isDirectory to be true.
However, '/Users/kasper/tmp' asFileReference asZnUrl isDirectoryPath returns false.

The reason for the difference is that the implementation of asZnUrl for file references are based on paths

AbstractFilePath>>asZnUrl
	^ self asAbsolute path asZnUrl

Basing the implementation on the path looses the information that '/Users/kasper/tmp' is a directory.

We have a chokepoint in our code which will allow us to encapsulate this, so we can work around our specific problem. But the question is if the implementation above should really be:

AbstractFilePath>>asZnUrl
	^ self isDirectory 
		ifTrue: [ ('file:',self pathString , '/') asZnUrl ]
		ifFalse: [ self asAbsolute path asZnUrl ]

I am sure you know a better implementation, but this seems to work - that is '/Users/kasper/tmp' asFileReference asZnUrl isDirectoryPath returns true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions