7676 ; The authority component is preceded by a double slash ("//") and is
7777 ; terminated by the next slash ("/"), question mark ("?"), or number
7878 ; sign ("#") character, or by the end of the URI.
79- ; RFC 3986 - 3.1. Scheme
79+ ; RFC 3986 - 3.2. Authority
8080 (capability 'authority (list
8181
8282 (define (assert-authority authority-string url-string)
8888 (string-downcase (url-authority (url-parse url-string)))))
8989
9090 (test "basic authority" (lambda ()
91- (assert-authority "named-authority" "scheme://named-authority/path")))
91+ (assert-authority "named-authority" "scheme://named-authority/path")
92+ (assert-authority "named-authority" "scheme://named-authority?query")
93+ (assert-authority "named-authority" "scheme://named-authority#fragment")
94+ (assert-authority "named-authority" "scheme://named-authority")))
95+
96+ (test "basic not-a-authority" (lambda ()
97+ (assert-authority "" "mailto:test@recipient.org")
98+ (assert-authority "" "some-prot:/path:100")))
9299
93100 ; Host parts
94101 ; RFC 3986 - 3.2.2. Host
233240
234241 ))
235242
243+ ; The path is terminated by the first question mark ("?") or
244+ ; number sign ("#") character, or by the end of the URI. If a
245+ ; URI contains an authority component, then the path component
246+ ; must either be empty or begin with a slash ("/") character.
247+ ; RFC 3986 - 3.3. Path
248+ (capability 'path (list
249+
250+ (define (assert-path path-string url-string)
251+ (assert
252+ (not (parse-error? (url-parse url-string)))
253+ (string-append "Failed to parse URL: " url-string))
254+ (assert-equal
255+ (string-downcase path-string)
256+ (string-downcase (url-path (url-parse url-string)))))
257+
258+
259+
260+
261+ ; If a URI does not contain an authority component, then the
262+ ; path cannot begin with two slash characters ("//").
263+ ; RFC 3986 - 3.3. Path
264+
265+
266+ ; In addition, a URI reference (Section 4.1) may be a relative-path
267+ ; reference, in which case the first path segment cannot contain a
268+ ; colon (":") character.
269+
270+ ))
271+
272+
236273))
0 commit comments