[Pharo-dev] ZnEasy question

Sven Van Caekenberghe sven at stfx.eu
Thu Aug 17 12:51:42 EDT 2017


Hi Milton,

> On 5 Aug 2017, at 03:15, milton mamani <akevalion at gmail.com> wrote:
> 
> Hi to all
> 
> I want to use the next instruction in my code
> 
> response := ZnEasy get: 'https://archive.softwareheritage.org/api/1/origin/git/url/https://github.com/hylang/hy'.
> response.
> 
> The previous code works from command line or in a webbrowser, but I does not work with ZnEasy
> Because it takes the previous link as:
> a ZnRequest(GET /api/1/origin/git/url/https:/github.com/hylang/hy)
> 
> Could you please tell me what can I do for this situation?
> 
> Cheers,
> Milton

ZnUrl has indeed a problem parsing this URL. It skips empty path segments, we'll have to create an issue for that and we should try to fix it, maintaining current behaviour. The parser is hand written and has evolved a bit over the years, so it is a bit brittle. Seaside's WAUrl seems to have the same problem. It is funny that this only now comes up. Thanks for reporting it.

Here is a workaround, by manually creating a ZnUrl object from its elementary components.

ZnUrl new scheme: #https; host: 'archive.softwareheritage.org'; addPathSegments: #('api' '1' 'origin' 'git' 'url' 'https:' '' 'github.com' 'hylang' 'hy'); yourself.

You can use this as follows.

ZnUrl new scheme: #https; host: 'archive.softwareheritage.org'; addPathSegments: #('api' '1' 'origin' 'git' 'url' 'https:' '' 'github.com' 'hylang' 'hy'); retrieveContents.

ZnEasy get: (ZnUrl new scheme: #https; host: 'archive.softwareheritage.org'; addPathSegments: #('api' '1' 'origin' 'git' 'url' 'https:' '' 'github.com' 'hylang' 'hy'); yourself).

Regards,

Sven




More information about the Pharo-dev mailing list