/lib/web.arc.t

http://github.com/alimoeeny/arc · Raku · 41 lines · 40 code · 1 blank · 0 comment · 0 complexity · 32c114dfa4deb86a0f91c4799b76118e MD5 · raw file

  1. (require "lib/arctap.arc")
  2. (test-iso "split-by works"
  3. '("abc" "d")
  4. (split-by "#" "abc#d"))
  5. (test-iso "strip-after works"
  6. "abc"
  7. (strip-after "abc#d" "#"))
  8. (test-iso "strip-after works when delimiter is absent"
  9. "abc"
  10. (strip-after "abc" "#"))
  11. (test-iso "parse-url works"
  12. (obj resource "http" host "example.com" port 80 filename "foo")
  13. (parse-url "http://example.com/foo"))
  14. (test-iso "parse-url detects port"
  15. (obj resource "http" host "example.com" port 81 filename "foo")
  16. (parse-url "http://example.com:81/foo"))
  17. (test-iso "parse-url detects nested directories"
  18. (obj resource "http" host "example.com" port 81 filename "foo/bar")
  19. (parse-url "http://example.com:81/foo/bar"))
  20. (test-iso "parse-url gives https the right port"
  21. (obj resource "https" host "example.com" port 443 filename "foo/bar")
  22. (parse-url "https://example.com/foo/bar"))
  23. (test-iso "parse-url makes url http by default"
  24. (obj resource "http" host "example.com" port 81 filename "foo/bar")
  25. (parse-url "example.com:81/foo/bar"))
  26. (test-iso "parse-url ignores anchor"
  27. (obj resource "http" host "example.com" port 80 filename "foo")
  28. (parse-url "http://example.com/foo#anchor"))
  29. (test-iso "parse-url handles query string"
  30. (obj resource "http" host "example.com" port 80 filename "foo" query "bar=blah")
  31. (parse-url "http://example.com/foo?bar=blah#anchor"))