rfc2396 1.1.0

A library for validating strings as RFC2396-compliant URIs
Documentation
use anyhow::Context;

test_cases! {
    uri::uri_reference: {
        case_ampersand_count: "&count=one&count=two&count=three",
        case_ampersand_escaped: "&semi=%3B&dot=.&comma=%2C",
        case_ampersand_half: "&half=50%25",
        case_ampersand_keys: "&keys=semi,%3B,dot,.,comma,%2C",
        case_ampersand_list_ampersand_delim: "&list=red&list=green&list=blue",
        case_ampersand_list_comma_delim: "&list=red,green,blue",
        case_ampersand_var: "&var=val",
        case_ampersand_who: "&who=fred",
        case_ampersand_x_y: "&x=1024&y=768",
        case_ampersand_x_y_empty: "&x=1024&y=768&empty=",
        case_base_index_escaped: "http%3A%2F%2Fexample.com%2Fhome%2Findex",
        case_comma_delim: "semi=;,dot=.,comma=,",
        case_comma_delim_comma_equal: "semi,%3B,dot,.,comma,%2C",
        case_comma_delim_escaped: "semi=%3B,dot=.,comma=%2C",
        case_current_dir: ".",
        case_current_dir_g: "./g",
        case_current_dir_resource: "./resource.txt",
        case_current_dir_slash: "./",
        case_domain: "//g",
        case_domain_path_resource: "//example.com/path/resource.txt",
        case_empty: "",
        case_example: "www.example.com",
        case_find: "find?year=1965&year=2000&year=2012",
        case_foo: "foo",
        case_foo_b_here: "/foo/b/here",
        case_foo_bar_here: "/foo/bar/here",
        case_foo_bar_x_here: "/foo/bar,1024/here",
        case_foo_hash: "foo#",
        case_fred: "/fred",
        case_fred_2: "/fred/fred",
        case_fred_me_too: "/fred/me%2Ftoo",
        case_g: "g",
        case_g_h: "g:h",
        case_g_s: "g#s",
        case_g_slash: "g/",
        case_g_x: "g;x",
        case_g_x_y_s: "g;x?y#s",
        case_g_y: "g?y",
        case_g_y_s: "g?y#s",
        case_half: "50%25",
        case_half_fred: "/50%25/fred",
        case_hash_comma_delim: "#semi,;,dot,.,comma,,",
        case_hash_foo_b_here: "#/foo/b/here",
        case_hash_foo_bar_here: "#/foo/bar,1024/here",
        case_hash_fragment: "#fragment",
        case_hash_half: "#50%25",
        case_hash_hello: "#Hello%20World!",
        case_hash_red_green_blue: "#red,green,blue",
        case_hash_s: "#s",
        case_hash_semi_delim: "#semi=;,dot=.,comma=,",
        case_hash_value: "#value",
        case_hash_x_hello_y: "#1024,Hello%20World!,768",
        case_hello: "Hello%20World!",
        case_hello_escaped: "Hello%20World%21",
        case_here_ref_foo_bar: "here?ref=/foo/bar",
        case_http_a: "http://a/",
        case_http_a_b: "http://a/b/",
        case_http_a_b_c: "http://a/b/c/",
        case_http_a_b_c_d_p_q: "http://a/b/c/d;p?q",
        case_http_a_b_c_d_p_q_s: "http://a/b/c/d;p?q#s",
        case_http_a_b_c_d_p_y: "http://a/b/c/d;p?y",
        case_http_a_b_c_g: "http://a/b/c/g",
        case_http_a_b_c_g_s: "http://a/b/c/g#s",
        case_http_a_b_c_g_slash: "http://a/b/c/g/",
        case_http_a_b_c_g_x: "http://a/b/c/g;x",
        case_http_a_b_c_g_x_y_s: "http://a/b/c/g;x?y#s",
        case_http_a_b_c_g_y: "http://a/b/c/g?y",
        case_http_a_b_c_g_y_s: "http://a/b/c/g?y#s",
        case_http_a_b_c_x: "http://a/b/c/;x",
        case_http_a_b_g: "http://a/b/g",
        case_http_a_g: "http://a/g",
        case_http_dev_plex: "http://dev.plexapp.com/docs/agents/models.html",
        case_http_devgrok: "http://www.devgrok.com/2015/03/developing-plex-media-server-plugins.html",
        case_http_example: "http://example.com",
        case_http_example_dict_c: "http://example.com/dictionary/c/cat",
        case_http_example_dict_d: "http://example.com/dictionary/d/dog",
        case_http_example_foo: "http://www.example.com/foo",
        case_http_example_foo_number: "http://www.example.com/foo?number=100",
        case_http_example_foo_query: "http://www.example.com/foo?query=mycelium&number=100",
        case_http_example_fred: "http://example.com/~fred/",
        case_http_example_home: "http://example.com/home/index",
        case_http_example_mark: "http://example.com/~mark/",
        case_http_example_search_en: "http://example.com/search?q=cat&lang=en",
        case_http_example_search_fr: "http://example.com/search?q=chien&lang=fr",
        case_http_example_wiki: "http://example.org/wiki/Main_Page",
        case_http_g: "http://g",
        case_http_localhost: "http://127.0.0.1",
        case_http_permissions: "http://permissions-calculator.org/",
        case_http_unit: "http://www.unit-conversion.info/texttools/random-string-generator/",
        case_https_alt: "https://alternativeto.net/",
        case_https_animelab: "https://www.animelab.com/racks/watchlist",
        case_https_app_plex: "https://app.plex.tv",
        case_https_archive: "https://web.archive.org/web/20150113085312/",
        case_https_auspost: "https://auspost.com.au/auth/login?caller=DELIVERIES_DELIVERY_OPTION&product=MYPOST_CONSUMER&channel=WEB",
        case_https_bsaber: "https://bsaber.com/curator-recommended/page/34/",
        case_https_cabs: "https://book.13cabs.com.au/",
        case_https_coles: "https://shop.coles.com.au/a/rockhampton-nth/home",
        case_https_computeralliance: "https://www.computeralliance.com.au/",
        case_https_crates: "https://crates.io/",
        case_https_crunchyroll: "https://www.crunchyroll.com/home/queue",
        case_https_dev_moz: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status",
        case_https_drive: "https://drive.google.com/drive/my-drive",
        case_https_epoch: "https://www.epochconverter.com/",
        case_https_euler: "https://projecteuler.net/",
        case_https_example: "https://example.com/path/resource.txt#fragment",
        case_https_file: "https://www.fileformat.info/info/unicode/char/search.htm",
        case_https_font: "https://fontawesome.com/icons?d=gallery",
        case_https_forum_plex_doc: "https://forums.plex.tv/t/plugin-development-documentation/107751",
        case_https_forum_plex_walkthrough: "https://forums.plex.tv/t/plex-plugin-development-walkthrough/9909",
        case_https_gdnative: "https://docs.rs/gdnative/0.9.1/gdnative/index.html",
        case_https_github_cc: "https://github.com/SquidDev-CC/CC-Tweaked/tree/fff8353451451be5ae31e0f63d8e529b127fd186/src/main/resources/data/computercraft/lua",
        case_https_github_cpython: "https://github.com/dgrunwald/rust-cpython",
        case_https_github_example: "https://github.com/Example-User?tab=repositories",
        case_https_github_lucky: "https://github.com/luckytoilet/projecteuler-solutions",
        case_https_github_plex: "https://github.com/squaresmile/Plex-Plug-Ins",
        case_https_github_raml: "https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#base-uri-and-base-uri-parameters",
        case_https_gitlab: "https://gitlab.com/",
        case_https_godot: "https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html",
        case_https_guid: "https://www.guidgenerator.com/",
        case_https_ietf: "https://www.ietf.org/rfc/rfc2396.txt",
        case_https_ipaddress: "https://www.ipaddressguide.com/cidr",
        case_https_ipcheck: "https://www.ipchecktool.com/tool/macfinder",
        case_https_john: "https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top",
        case_https_mwave: "https://www.mwave.com.au/",
        case_https_office: "https://www.office.com/launch/excel?ui=en-US&rs=AU&auth=1",
        case_https_pascall: "https://www.pascallandau.com/blog/setup-phpstorm-with-xdebug-on-docker/",
        case_https_pccasegear: "https://www.pccasegear.com/account",
        case_https_ple: "https://www.ple.com.au/MyPLE.aspx",
        case_https_raildex: "https://toarumajutsunoindex.fandom.com/wiki/Anime_Timeline",
        case_https_regex: "https://regex101.com/",
        case_https_roman: "https://roman-numerals.info/",
        case_https_scorptec: "https://www.scorptec.com.au/",
        case_https_survey: "https://www.soscisurvey.de/tools/view-chars.php",
        case_https_umart: "https://www.umart.com.au/",
        case_https_url: "https://www.urlencoder.org/",
        case_https_wiki: "https://en.wikipedia.org/wiki/Uniform_Resource_Identifier",
        case_https_woolies: "https://www.woolworths.com.au/",
        case_https_yt: "https://www.youtube.com/feed/subscriptions",
        case_isbn: "urn:isbn:0-486-27557-4",
        case_ldap: "ldap://120.0.8.7/c=GB?objectClass?one",
        case_list_colours: "red,green,blue",
        case_list_numbers: "one,two,three",
        case_mail: "mailto:John.Doe@example.com",
        case_mapper: "/mapper?city=Newport%20Beach&state=CA",
        case_news: "news:comp.infosystems.www.servers.unix",
        case_oasis: "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
        case_one_two_three_comma_delim: "/one,two,three",
        case_one_two_three_slash_delim: "/one/two/three",
        case_parent_dir: "..",
        case_parent_dir_2: "../..",
        case_parent_dir_2_g: "../../g",
        case_parent_dir_2_slash: "../../",
        case_parent_dir_g: "../g",
        case_parent_dir_resource: "../resource.txt",
        case_parent_dir_slash: "../",
        case_path_resource: "path/resource.txt",
        case_period_fred: ".fred",
        case_period_fred_2: ".fred.fred",
        case_period_half_fred: ".50%25.fred",
        case_red_green_blue_comma_delim: "/red,green,blue",
        case_red_green_blue_foo: "/red/green/blue/%2Ffoo",
        case_red_green_blue_slash_delim: "/red/green/blue",
        case_resource: "resource.txt",
        case_semi_count_list: ";count=one,two,three",
        case_semi_count_params: ";count=one;count=two;count=three",
        case_semi_delim: "semi,;,dot,.,comma,,",
        case_semi_empty: ";empty",
        case_semi_half: ";half=50%25",
        case_semi_hello: ";hello=Hello",
        case_semi_keys: ";keys=semi,%3B,dot,.,comma,%2C",
        case_semi_list_comma_delim: ";list=red,green,blue",
        case_semi_list_semi_delim: ";list=red;list=green;list=blue",
        case_semi_semi_delim_escaped: ";semi=%3B;dot=.;comma=%2C",
        case_semi_v_empty_who: ";v=6;empty;who=fred",
        case_semi_v_who: ";v=6;who=fred",
        case_semi_who: ";who=fred",
        case_semi_x: ";x",
        case_semi_x_y: ";x=1024;y=768",
        case_semi_x_y_empty: ";x=1024;y=768;empty",
        case_slash_comma_delim_escaped: "/semi,%3B,dot,.,comma,%2C",
        case_slash_delim_escaped: "/semi=%3B/dot=./comma=%2C",
        case_slash_g: "/g",
        case_slash_path_resource: "/path/resource.txt",
        case_slash_value: "/value",
        case_tel: "tel:+1-816-555-1212",
        case_telnet: "telnet://192.0.2.16:80/",
        case_up_foo_barvalue_here: "up/foo/barvalue/here",
        case_v_value: "/v/value",
        case_val: "val",
        case_value: "value",
        case_value_here: "/value/1024/here",
        case_value_slash: "/value/",
        case_wiki: "/wiki/Main_Page",
        case_x: "X",
        case_x_hello_escaped_y: "1024,Hello%20World%21,768",
        case_x_hello_y: "1024,Hello%20World!,768",
        case_x_period: "X.",
        case_x_period_comma_delim: "X.red,green,blue",
        case_x_period_period_delim: "X.red.green.blue",
        case_x_semi_dot_comma_comma_delim: "X.semi,%3B,dot,.,comma,%2C",
        case_x_semi_dot_comma_period_delim: "X.semi=%3B.dot=..comma=%2C",
        case_x_val: "X.val",
        case_x_value: "X.value",
        case_x_y: "1024,768"
    }
}