Issue 3401 in pharo: Comparison of Urls is not possible yet

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 3401 in pharo: Comparison of Urls is not possible yet

pharo
Status: Accepted
Owner: cdrick65
Labels: Type-RequestForEnhancement

New issue 3401 by cdrick65: Comparison of Urls is not possible yet
http://code.google.com/p/pharo/issues/detail?id=3401

Pharo image: 1.1 dev
Pharo core version: 11414
Virtual machine used: cog osx

not possible to compare url's
'http://www.pharo-project.org' asUrl = 'http://www.pharo-project.org' 
asUrl.   => false
(i know asUrl is deprecated but... shorter ;) )

I actually copy/pasted = and hash from URI (common superclass ?  traits ?)
I also made a test for urls.







if yes, is the following proposition enough ?
or should it be more precise according to each subclass ?

See you



'http://www.pharo-project.org' asUrl = 'http://www.pharo-project.org' 
asUrl.   => false

What about having:

Url>> = anotherUrl

     ^self asText = anotherUrl asText


Paste or attach stack trace if applicable (look at the file PharoDebug.log
located in the same directory as your image):


Attachments:
        Url-comparing.st  414 bytes
        UrlTest-testUrlComparison.st  733 bytes


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3401 in pharo: Comparison of Urls is not possible yet

pharo
Updates:
        Status: FixProposed

Comment #1 on issue 3401 by [hidden email]: Comparison of Urls is  
not possible yet
http://code.google.com/p/pharo/issues/detail?id=3401

In PharoInbox:  
SLICE-Issue-3401-Comparison-of-Urls-is-not-possible-yet-LaurentLaffont.1

Integration of changeset submitted by Cedrick


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3401 in pharo: Comparison of Urls is not possible yet

pharo

Comment #2 on issue 3401 by [hidden email]: Comparison of Urls is  
not possible yet
http://code.google.com/p/pharo/issues/detail?id=3401

The URL/URI classes/hierarchy is problematic, so there is no easy solution.  
I know that Cedrick is just trying to help here.

But converting an object to its string representation to compare it feels  
wrong (inefficient, incorrect, lazy, inelegant).

The point of having an object representing something using semanticaly  
meaningful parts is to do useful things with it, like comparing two  
instances.

In ZnUrl (a class only dealing with HTTP URLs) I did implement #=, but not  
to my full satisfaction. This is a hard problem, consider some of the  
following:

http://www.pharo.st = pharo.st
http://www.pharo.st:80 = http://www.pharo.st
http://www.pharo.st/ = http://www.pharo.st

And this is only in the context of HTTP.

Sven




Reply | Threaded
Open this post in threaded view
|

Re: Issue 3401 in pharo: Comparison of Urls is not possible yet

pharo

Comment #3 on issue 3401 by [hidden email]: Comparison of Urls is  
not possible yet
http://code.google.com/p/pharo/issues/detail?id=3401

I want to add to Sven comments, which not only I second in full, but also  
because converting URI/URLs to strings to do comparisons will not cut in.

Staying just in the context of HTTP as Sven points out, what it is the  
expected semantics in comparing two URLs?  Should an alias of a URL be  
considered 'equal' to the aliased URL as tinyurl service produces?

What about URLs with parameters whose order often doesn't matter, but from  
a string perspective they would be 'different'?



Reply | Threaded
Open this post in threaded view
|

Re: Issue 3401 in pharo: Comparison of Urls is not possible yet

pharo

Comment #4 on issue 3401 by [hidden email]: Comparison of Urls is not  
possible yet
http://code.google.com/p/pharo/issues/detail?id=3401

I totally agree with previous comments. But then, #= in URI should be  
refactored too as it is also based on string conversion.

URI>>= otherURI
        ^ self class = otherURI class
                and: [self asString = otherURI asString]

Time to refactor URI/Url ? :)


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3401 in pharo: Comparison of Urls is not possible yet

pharo

Comment #5 on issue 3401 by [hidden email]: Comparison of Urls is  
not possible yet
http://code.google.com/p/pharo/issues/detail?id=3401

Yessssss please propose something :)