File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed
http-easy-lib/http-easy/private
http-easy-test/net/http-easy/private Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 282
282
(string->url/literal location))
283
283
(cond
284
284
[(url-host location-url) location-url]
285
- [else (struct-copy
286
- url/literal location-url
287
- [scheme #:parent url (url-scheme orig)]
288
- [user #:parent url (url-user orig)]
289
- [host #:parent url (url-host orig)]
290
- [port #:parent url (url-port orig)])]))
285
+ [(not (url-path-absolute? location-url))
286
+ (error 'ensure-absolute-url "Location destination is relative " )]
287
+ [else
288
+ (struct-copy
289
+ url/literal location-url
290
+ [scheme #:parent url (url-scheme orig)]
291
+ [user #:parent url (url-user orig)]
292
+ [host #:parent url (url-host orig)]
293
+ [port #:parent url (url-port orig)])]))
291
294
292
295
(define (same-origin? a b)
293
296
(and
Original file line number Diff line number Diff line change 55
55
(url/literal scheme user host port abs? path query fragment)))
56
56
57
57
(define (url/literal->string u)
58
- (match-define (url scheme user host port _ path query fragment) u)
58
+ (match-define (url scheme user host port abs? path query fragment) u)
59
59
(call-with-output-string
60
60
(lambda (out)
61
61
(when scheme
82
82
(write-string "// " out)]
83
83
[else
84
84
(void)])
85
- (let loop ([path-components path] )
86
- (unless (null? path-components )
87
- (write-char #\/ out )
85
+ (unless (null? path)
86
+ (when abs? (write-char #\/ out) )
87
+ ( let loop ([path-components path] )
88
88
(match-define (path/param path params)
89
89
(car path-components))
90
90
(write-string
91
91
(maybe-percent-encode
92
92
(string-append path (string-join params "; " ))
93
93
uri-path-segment-encode)
94
94
out)
95
- (loop (cdr path-components))))
95
+ (unless (null? (cdr path-components))
96
+ (write-char #\/ out)
97
+ (loop (cdr path-components)))))
96
98
(unless (null? query)
97
99
(write-char #\? out)
98
100
(for* ([pair (in-list query)]
Original file line number Diff line number Diff line change 65
65
66
66
("http://example.com/a/b/c " . "http://example.com/a/b/c " )
67
67
("http://example.com/a%2Bb.mp3 " . "http://example.com/a%2Bb.mp3 " )
68
- ("http://example.com/a%2Bb.mp3?c=d+e " . "http://example.com/a%2Bb.mp3?c=d%2Be " )))
68
+ ("http://example.com/a%2Bb.mp3?c=d+e " . "http://example.com/a%2Bb.mp3?c=d%2Be " )
69
+ ("a/b/c " . "a/b/c " )
70
+ ("/a/b/c " . "/a/b/c " )))
69
71
70
72
(for* ([pair (in-list tests)]
71
73
[s (in-value (car pair))]
You can’t perform that action at this time.
0 commit comments