~ chicken-core (chicken-5) 8833978ae542bfa83c4ae9a0410b9664348b9997
commit 8833978ae542bfa83c4ae9a0410b9664348b9997
Author: Mario Domenech Goulart <mario.goulart@gmail.com>
AuthorDate: Sat Mar 2 14:48:16 2013 -0300
Commit: Peter Bex <peter.bex@xs4all.nl>
CommitDate: Sun Mar 3 11:56:34 2013 +0100
setup-download: fix +url-regex+ and deconstruct-url to match urls with path=/ or no path when port number is provided
Without this patch, we get:
(deconstruct-url "http://localhost:8080")
=> (values "http://localhost:8080" 80 "/")
(deconstruct-url "http://localhost:8080/")
=> (values "http://localhost:8080/" 80 "/")
That behavior makes chicken-install request port 80, even if
another port was requested (8080, in the examples). Also, it
returns host as "http://localhost:8080" instead of "localhost".
This patch makes deconstruct-url correctly handle / and no path
when a port is provided:
(deconstruct-url "http://localhost:8080")
=> (values "localhost" 8080 "/")
(deconstruct-url "http://localhost:8080/")
=> (values "localhost" 8080 "/")
Signed-off-by: Peter Bex <peter.bex@xs4all.nl>
diff --git a/setup-download.scm b/setup-download.scm
index 5267b22a..30934c4b 100644
--- a/setup-download.scm
+++ b/setup-download.scm
@@ -44,7 +44,7 @@
(define-constant +default-tcp-connect-timeout+ 30000) ; 30 seconds
(define-constant +default-tcp-read/write-timeout+ 30000) ; 30 seconds
- (define-constant +url-regex+ "(http://)?([^/:]+)(:([^:/]+))?(/.+)")
+ (define-constant +url-regex+ "(http://)?([^/:]+)(:([^:/]+))?(/.*)?")
(tcp-connect-timeout +default-tcp-connect-timeout+)
(tcp-read-timeout +default-tcp-read/write-timeout+)
@@ -226,7 +226,8 @@
(or (string->number port)
(error "not a valid port" port)))
80)
- (if m (irregex-match-substring m 5) "/")) ) )
+ (or (and m (irregex-match-substring m 5))
+ "/"))))
(define (locate-egg/http egg url #!optional version destination tests
proxy-host proxy-port proxy-user-pass)
Trap