Skip to content

Commit

Permalink
lense: add RFC3986 URL regex (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk committed Jun 2, 2020
1 parent e615ab1 commit e9876c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lenses/rx.aug
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,7 @@ let time =
in let zone = "Z" | /[-+]?[0-9]{2}(:?[0-9]{2})?/
in sep . digits . precis? . zone?
let iso_8601 = year . ("-"? . monthday . time?)?

(* Variable: url_3986
A valid RFC 3986 url - See Appendix B *)
let url_3986 = /(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/
11 changes: 11 additions & 0 deletions lenses/tests/test_rx.aug
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ test iso_8601 get "2010-02-18T16.23334444" = { "date" = "2010-02-18T16.23334444"
test iso_8601 get "2010-02-18T16,2283" = { "date" = "2010-02-18T16,2283" }
test iso_8601 get "2009-05-19 143922.500" = { "date" = "2009-05-19 143922.500" }
test iso_8601 get "2009-05-19 1439,55" = { "date" = "2009-05-19 1439,55" }

(* url_3986 *)
let url_3986 = [ label "url" . store Rx.url_3986 ]

test url_3986 get "http://tools.ietf.org/rfc/rfc3986.txt" = { "url" = "http://tools.ietf.org/rfc/rfc3986.txt" }
test url_3986 get "https://github.com/hercules-team/augeas/" = { "url" = "https://github.com/hercules-team/augeas/" }
test url_3986 get "http://www.ics.uci.edu:80/pub/ietf/uri/#Related" = { "url" = "http://www.ics.uci.edu:80/pub/ietf/uri/#Related" }
test url_3986 get "EXAMPLE://a/./b/../b/%63/%7bfoo%7d" = { "url" = "EXAMPLE://a/./b/../b/%63/%7bfoo%7d" }
test url_3986 get "http://a/b/c/g;?x=1/y#z" = { "url" = "http://a/b/c/g;?x=1/y#z" }
test url_3986 get "eXaMpLe://a.very.sub.domain.tld:1234/b/c/e/f/g.txt;?x=1/y&q=%7b-w-%7b#z" = { "url" = "eXaMpLe://a.very.sub.domain.tld:1234/b/c/e/f/g.txt;?x=1/y&q=%7b-w-%7b#z" }

0 comments on commit e9876c4

Please sign in to comment.