|
6 | 6 | racket/file |
7 | 7 | racket/runtime-path |
8 | 8 | rackunit |
9 | | - splitflap/private/validation |
10 | | - splitflap/private/feed) |
| 9 | + splitflap) |
11 | 10 |
|
12 | 11 | ;; ~~ DNS Domain validation (RFC 1035) ~~~~~~~~~~~ |
13 | 12 |
|
|
75 | 74 | (check-false (valid-url-string? "ldap://[2001:db8::7]/c=GB?objectClass?one")) |
76 | 75 | (check-false (valid-url-string? "telnet://192.0.2.16:80/")) |
77 | 76 |
|
| 77 | +;; ~~ URL convenience functions ~~~~~~~~~~~~~~~~~~ |
| 78 | + |
| 79 | +(check-equal? (url-domain "http://example.com") "example.com") |
| 80 | +(check-equal? (url-domain "https://user:p@example.com:8080/path/to/file") "example.com") |
| 81 | +(check-exn exn:fail:contract? (lambda () (url-domain "x"))) |
| 82 | + |
| 83 | +;; ensure paths are tested accurately on all platforms |
| 84 | +(define rel-path (build-path "path" "to" "my file.html")) |
| 85 | +(check-true (relative-path? rel-path)) |
| 86 | +(define abs-path (path->complete-path rel-path)) |
| 87 | +(check-true (absolute-path? abs-path)) |
| 88 | + |
| 89 | +(check-equal? (url-join "http://example.com" rel-path) ; bare domain w/o trailing slash |
| 90 | + "http://example.com/path/to/my%20file.html") |
| 91 | +(check-equal? (url-join "http://example.com/" rel-path) ; bare domain w/trailing slash |
| 92 | + "http://example.com/path/to/my%20file.html") |
| 93 | +(check-equal? (url-join "http://example.com/dir/final" rel-path) ; final elem w/o trailing slash removed |
| 94 | + "http://example.com/dir/path/to/my%20file.html") |
| 95 | +(check-equal? (url-join "http://example.com/my dir/" rel-path) ; final element w/trailing slash kept |
| 96 | + "http://example.com/my%20dir/path/to/my%20file.html") |
| 97 | +(check-exn exn:fail:contract? (lambda () (url-join "x" "x"))) ; invalid URL string |
| 98 | +(check-exn exn:fail:contract? (lambda () (url-join "http://example.com" abs-path))) ; no absolute paths |
| 99 | + |
78 | 100 | ;; ~~ Tag URIs (RFC 4151) ~~~~~~~~~~~~~~~~~~~~~~~~ |
79 | 101 | (check-true (tag-specific-string? "abcdefghijklmnopqrstuvwxyz0123456789")) |
80 | 102 | (check-true (tag-specific-string? "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) |
|
0 commit comments