From 1fc417b61d59651c50875ca67abdf645cded0dd5 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 23 Sep 2015 10:31:15 -0400 Subject: [PATCH] Cope with trailing slashes in git: urls --- src/site.rkt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/site.rkt b/src/site.rkt index b1c69c5..5981e0d 100644 --- a/src/site.rkt +++ b/src/site.rkt @@ -1163,6 +1163,9 @@ 'source_url (package-url->useful-url source))))) ;; Copied from meta/pkg-index/official/static.rkt +;; Modified slightly to recognise additional ad-hockery +;; e.g. git://github.com/user/repo/ as well as +;; git://github.com/user/repo (note no trailing slash) (define (package-url->useful-url pkg-url-str) (define pkg-url (string->url pkg-url-str)) @@ -1178,15 +1181,16 @@ [_ pkg-url-str])] ["git" - (match (url-path pkg-url) + (match (map path/param-path (url-path pkg-url)) ;; xxx make this more robust - [(list user repo) + [(or (list user repo) + (list user repo "")) (url->string (struct-copy url pkg-url [scheme "http"] - [path (list user repo (path/param "tree" '()) - (path/param "master" '()))]))] + [path (map (lambda (x) (path/param x '())) + (list user repo "tree" "master"))]))] [_ pkg-url-str])] [_