Compare commits
	
		
			30 Commits
		
	
	
		
			v2.0.0
			...
			7b7e689892
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 7b7e689892 | |||
| 22d13bdf7d | |||
| 3fc9a61afe | |||
| b9d1077425 | |||
| 3cd6d5d4af | |||
| a00af69b56 | |||
| c6ee27fa7a | |||
| 5c4a444231 | |||
| 452117db63 | |||
| 5da4ea66b1 | |||
| 321e203778 | |||
| 1ac5e05e1a | |||
| cc110b414f | |||
| 246706d4fc | |||
| 897124be27 | |||
| 027f94e666 | |||
| 869c5cf06c | |||
| 67798d1dcf | |||
| 6131aa01e7 | |||
| 2ee6741308 | |||
| e5b5545bd1 | |||
| 47da8071cf | |||
| 8b8d3e577e | |||
| 4cad0c5bc3 | |||
| 0e293fc85e | |||
| 4d29a5de5a | |||
| 1174a17c97 | |||
| 428bd53002 | |||
| 91bfe0285f | |||
| e13f80c483 | 
							
								
								
									
										6
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							@@ -14,10 +14,10 @@ jobs:
 | 
				
			|||||||
      - uses: actions/checkout@v4
 | 
					      - uses: actions/checkout@v4
 | 
				
			||||||
      - uses: erlef/setup-beam@v1
 | 
					      - uses: erlef/setup-beam@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          otp-version: "27.1.2"
 | 
					          otp-version: "28.1"
 | 
				
			||||||
          gleam-version: "1.12.0"
 | 
					          gleam-version: "1.12.0"
 | 
				
			||||||
          rebar3-version: "3"
 | 
					          rebar3-version: "3.25.1"
 | 
				
			||||||
          # elixir-version: "1"
 | 
					          elixir-version: "1.18.4"
 | 
				
			||||||
      - run: gleam deps download
 | 
					      - run: gleam deps download
 | 
				
			||||||
      - run: gleam test
 | 
					      - run: gleam test
 | 
				
			||||||
      - run: gleam format --check src test
 | 
					      - run: gleam format --check src test
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -2,3 +2,4 @@
 | 
				
			|||||||
*.ez
 | 
					*.ez
 | 
				
			||||||
/build
 | 
					/build
 | 
				
			||||||
erl_crash.dump
 | 
					erl_crash.dump
 | 
				
			||||||
 | 
					node_modules
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								CHANGELOG.md
									
									
									
									
									
								
							@@ -7,3 +7,18 @@
 | 
				
			|||||||
## v2.0.0
 | 
					## v2.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Removed types.Uri. Now gluri uses the stdlib Uri type (and empty)
 | 
					- Removed types.Uri. Now gluri uses the stdlib Uri type (and empty)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## v2.0.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Improved parsing performance significantly and reduced memory usage up to 50%
 | 
				
			||||||
 | 
					- Significantly improved IPV4 parsing performance
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## v2.0.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Minor performance improvement for uris with userinfo
 | 
				
			||||||
 | 
					- More performance improvements for ascii/digit parsing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 2.0.3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Minor performance improvement for erlang
 | 
				
			||||||
 | 
					- Major performance improvement for js
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
name = "gluri"
 | 
					name = "gluri"
 | 
				
			||||||
version = "2.0.0"
 | 
					version = "2.0.3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Fill out these fields if you intend to generate HTML documentation or publish
 | 
					# Fill out these fields if you intend to generate HTML documentation or publish
 | 
				
			||||||
# your project to the Hex package manager.
 | 
					# your project to the Hex package manager.
 | 
				
			||||||
@@ -20,3 +20,4 @@ splitter = ">= 1.1.0 and < 2.0.0"
 | 
				
			|||||||
[dev-dependencies]
 | 
					[dev-dependencies]
 | 
				
			||||||
gleeunit = ">= 1.0.0 and < 2.0.0"
 | 
					gleeunit = ">= 1.0.0 and < 2.0.0"
 | 
				
			||||||
startest = ">= 0.7.0 and < 1.0.0"
 | 
					startest = ">= 0.7.0 and < 1.0.0"
 | 
				
			||||||
 | 
					glychee = ">= 1.1.2 and < 2.0.0"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,8 +3,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
packages = [
 | 
					packages = [
 | 
				
			||||||
  { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
 | 
					  { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
 | 
				
			||||||
 | 
					  { name = "benchee", version = "1.4.0", build_tools = ["mix"], requirements = ["deep_merge", "statistex", "table"], otp_app = "benchee", source = "hex", outer_checksum = "299CD10DD8CE51C9EA3DDB74BB150F93D25E968F93E4C1FA31698A8E4FA5D715" },
 | 
				
			||||||
  { name = "bigben", version = "1.0.1", build_tools = ["gleam"], requirements = ["birl", "gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "bigben", source = "hex", outer_checksum = "190E489610A80D76C48BACC75EB8314BD184FF0220AB0F251ABE760B993B91BB" },
 | 
					  { name = "bigben", version = "1.0.1", build_tools = ["gleam"], requirements = ["birl", "gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "bigben", source = "hex", outer_checksum = "190E489610A80D76C48BACC75EB8314BD184FF0220AB0F251ABE760B993B91BB" },
 | 
				
			||||||
  { name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
 | 
					  { name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
 | 
				
			||||||
 | 
					  { name = "deep_merge", version = "1.0.0", build_tools = ["mix"], requirements = [], otp_app = "deep_merge", source = "hex", outer_checksum = "CE708E5F094B9CD4E8F2BE4F00D2F4250C4095BE93F8CD6D018C753894885430" },
 | 
				
			||||||
  { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" },
 | 
					  { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" },
 | 
				
			||||||
  { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
 | 
					  { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
 | 
				
			||||||
  { name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" },
 | 
					  { name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" },
 | 
				
			||||||
@@ -14,21 +16,24 @@ packages = [
 | 
				
			|||||||
  { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" },
 | 
					  { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" },
 | 
				
			||||||
  { name = "gleam_otp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7987CBEBC8060B88F14575DEF546253F3116EBE2A5DA6FD82F38243FCE97C54B" },
 | 
					  { name = "gleam_otp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7987CBEBC8060B88F14575DEF546253F3116EBE2A5DA6FD82F38243FCE97C54B" },
 | 
				
			||||||
  { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
 | 
					  { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
 | 
				
			||||||
  { name = "gleam_stdlib", version = "0.63.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5E216C7D5E8BE22359C9D7DAA2CFBD66039BC12565542F34CD033C5BB57071ED" },
 | 
					  { name = "gleam_stdlib", version = "0.63.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "962B25C667DA07F4CAB32001F44D3C41C1A89E58E3BBA54F183B482CF6122150" },
 | 
				
			||||||
  { name = "gleam_time", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "DCDDC040CE97DA3D2A925CDBBA08D8A78681139745754A83998641C8A3F6587E" },
 | 
					  { name = "gleam_time", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "DCDDC040CE97DA3D2A925CDBBA08D8A78681139745754A83998641C8A3F6587E" },
 | 
				
			||||||
  { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
 | 
					  { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
 | 
				
			||||||
  { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
 | 
					  { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
 | 
				
			||||||
  { name = "glint", version = "1.2.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "2214C7CEFDE457CEE62140C3D4899B964E05236DA74E4243DFADF4AF29C382BB" },
 | 
					  { name = "glint", version = "1.2.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "2214C7CEFDE457CEE62140C3D4899B964E05236DA74E4243DFADF4AF29C382BB" },
 | 
				
			||||||
 | 
					  { name = "glychee", version = "1.1.2", build_tools = ["gleam"], requirements = ["benchee"], otp_app = "glychee", source = "hex", outer_checksum = "41784216C213F223095BB3FC3EDDB60CC537835B2340A868EA3931193F7F3824" },
 | 
				
			||||||
  { name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
 | 
					  { name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
 | 
				
			||||||
  { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
 | 
					  { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
 | 
				
			||||||
  { name = "snag", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "7E9F06390040EB5FAB392CE642771484136F2EC103A92AE11BA898C8167E6E17" },
 | 
					  { name = "snag", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "7E9F06390040EB5FAB392CE642771484136F2EC103A92AE11BA898C8167E6E17" },
 | 
				
			||||||
  { name = "splitter", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "05564A381580395DCDEFF4F88A64B021E8DAFA6540AE99B4623962F52976AA9D" },
 | 
					  { name = "splitter", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "05564A381580395DCDEFF4F88A64B021E8DAFA6540AE99B4623962F52976AA9D" },
 | 
				
			||||||
  { name = "startest", version = "0.7.0", build_tools = ["gleam"], requirements = ["argv", "bigben", "birl", "exception", "gleam_community_ansi", "gleam_erlang", "gleam_javascript", "gleam_regexp", "gleam_stdlib", "glint", "simplifile", "tom"], otp_app = "startest", source = "hex", outer_checksum = "71B9CB82C4B8779A4BD54C7151DF7D0B0F778D0DDE805B782B44EFA7BA8F50DA" },
 | 
					  { name = "startest", version = "0.7.0", build_tools = ["gleam"], requirements = ["argv", "bigben", "birl", "exception", "gleam_community_ansi", "gleam_erlang", "gleam_javascript", "gleam_regexp", "gleam_stdlib", "glint", "simplifile", "tom"], otp_app = "startest", source = "hex", outer_checksum = "71B9CB82C4B8779A4BD54C7151DF7D0B0F778D0DDE805B782B44EFA7BA8F50DA" },
 | 
				
			||||||
 | 
					  { name = "statistex", version = "1.1.0", build_tools = ["mix"], requirements = [], otp_app = "statistex", source = "hex", outer_checksum = "F5950EA26AD43246BA2CCE54324AC394A4E7408FDCF98B8E230F503A0CBA9CF5" },
 | 
				
			||||||
  { name = "tom", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_time"], otp_app = "tom", source = "hex", outer_checksum = "74D0C5A3761F7A7D06994755D4D5AD854122EF8E9F9F76A3E7547606D8C77091" },
 | 
					  { name = "tom", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_time"], otp_app = "tom", source = "hex", outer_checksum = "74D0C5A3761F7A7D06994755D4D5AD854122EF8E9F9F76A3E7547606D8C77091" },
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[requirements]
 | 
					[requirements]
 | 
				
			||||||
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
 | 
					gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
 | 
				
			||||||
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
 | 
					gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
 | 
				
			||||||
 | 
					glychee = { version = ">= 1.1.2 and < 2.0.0" }
 | 
				
			||||||
splitter = { version = ">= 1.1.0 and < 2.0.0" }
 | 
					splitter = { version = ">= 1.1.0 and < 2.0.0" }
 | 
				
			||||||
startest = { version = ">= 0.7.0 and < 1.0.0" }
 | 
					startest = { version = ">= 0.7.0 and < 1.0.0" }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "uri",
 | 
				
			||||||
 | 
					  "lockfileVersion": 3,
 | 
				
			||||||
 | 
					  "requires": true,
 | 
				
			||||||
 | 
					  "packages": {
 | 
				
			||||||
 | 
					    "": {
 | 
				
			||||||
 | 
					      "dependencies": {
 | 
				
			||||||
 | 
					        "mitata": "^1.0.34"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "node_modules/mitata": {
 | 
				
			||||||
 | 
					      "version": "1.0.34",
 | 
				
			||||||
 | 
					      "resolved": "https://registry.npmjs.org/mitata/-/mitata-1.0.34.tgz",
 | 
				
			||||||
 | 
					      "integrity": "sha512-Mc3zrtNBKIMeHSCQ0XqRLo1vbdIx1wvFV9c8NJAiyho6AjNfMY8bVhbS12bwciUdd1t4rj8099CH3N3NFahaUA==",
 | 
				
			||||||
 | 
					      "license": "MIT"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										6
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "type": "module",
 | 
				
			||||||
 | 
					  "dependencies": {
 | 
				
			||||||
 | 
					    "mitata": "^1.0.34"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -3,7 +3,7 @@ import gleam/int
 | 
				
			|||||||
import gleam/list
 | 
					import gleam/list
 | 
				
			||||||
import gleam/option.{Some}
 | 
					import gleam/option.{Some}
 | 
				
			||||||
import gleam/string
 | 
					import gleam/string
 | 
				
			||||||
import gleam/uri.{type Uri, Uri}
 | 
					import gleam/uri.{type Uri}
 | 
				
			||||||
import gluri/internal/parser
 | 
					import gluri/internal/parser
 | 
				
			||||||
import gluri/internal/utils
 | 
					import gluri/internal/utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -7,17 +7,21 @@ import gleam/string
 | 
				
			|||||||
import gleam/uri.{type Uri, Uri}
 | 
					import gleam/uri.{type Uri, Uri}
 | 
				
			||||||
import splitter.{type Splitter}
 | 
					import splitter.{type Splitter}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub const scheme_port = [
 | 
					type Scheme {
 | 
				
			||||||
  #("http", 80),
 | 
					  Scheme(name: String, port: Int)
 | 
				
			||||||
  #("https", 443),
 | 
					}
 | 
				
			||||||
  #("ftp", 21),
 | 
					
 | 
				
			||||||
  #("ws", 80),
 | 
					const scheme_port = [
 | 
				
			||||||
  #("wss", 443),
 | 
					  Scheme("http", 80),
 | 
				
			||||||
 | 
					  Scheme("https", 443),
 | 
				
			||||||
 | 
					  Scheme("ftp", 21),
 | 
				
			||||||
 | 
					  Scheme("ws", 80),
 | 
				
			||||||
 | 
					  Scheme("wss", 443),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn get_port_for_scheme(scheme: String) -> Option(Int) {
 | 
					pub fn get_port_for_scheme(scheme: String) -> Option(Int) {
 | 
				
			||||||
  list.find(scheme_port, fn(sp) { sp.0 == scheme })
 | 
					  list.find(scheme_port, fn(sp) { sp.name == scheme })
 | 
				
			||||||
  |> result.map(fn(sp) { sp.1 })
 | 
					  |> result.map(fn(sp) { sp.port })
 | 
				
			||||||
  |> option.from_result
 | 
					  |> option.from_result
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -82,6 +86,152 @@ fn merge_paths(base: Uri, relative: Uri) -> String {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn try_parsers(
 | 
				
			||||||
 | 
					  over list: List(fn(String) -> Result(#(a, String), Nil)),
 | 
				
			||||||
 | 
					  against static_data: String,
 | 
				
			||||||
 | 
					) -> Result(#(a, String), Nil) {
 | 
				
			||||||
 | 
					  case list {
 | 
				
			||||||
 | 
					    [] -> Error(Nil)
 | 
				
			||||||
 | 
					    [first, ..rest] ->
 | 
				
			||||||
 | 
					      case first(static_data) {
 | 
				
			||||||
 | 
					        Error(_) -> try_parsers(rest, static_data)
 | 
				
			||||||
 | 
					        Ok(r) -> Ok(r)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_min_max(
 | 
				
			||||||
 | 
					  str: f,
 | 
				
			||||||
 | 
					  min: Int,
 | 
				
			||||||
 | 
					  max: Int,
 | 
				
			||||||
 | 
					  parse_fn: fn(f) -> Result(#(String, f), g),
 | 
				
			||||||
 | 
					) -> Result(#(String, f), Nil) {
 | 
				
			||||||
 | 
					  do_parse_min_max(str, "", min, max, parse_fn)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn do_parse_min_max(
 | 
				
			||||||
 | 
					  str: d,
 | 
				
			||||||
 | 
					  acc: String,
 | 
				
			||||||
 | 
					  min: Int,
 | 
				
			||||||
 | 
					  max: Int,
 | 
				
			||||||
 | 
					  parse_fn: fn(d) -> Result(#(String, d), e),
 | 
				
			||||||
 | 
					) -> Result(#(String, d), Nil) {
 | 
				
			||||||
 | 
					  case parse_fn(str) {
 | 
				
			||||||
 | 
					    Error(_) -> {
 | 
				
			||||||
 | 
					      case min > 0 {
 | 
				
			||||||
 | 
					        True -> Error(Nil)
 | 
				
			||||||
 | 
					        False -> Ok(#(acc, str))
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    Ok(#(l, rest)) -> {
 | 
				
			||||||
 | 
					      case max {
 | 
				
			||||||
 | 
					        1 -> Ok(#(acc <> l, rest))
 | 
				
			||||||
 | 
					        _ -> do_parse_min_max(rest, acc <> l, min - 1, max - 1, parse_fn)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_optional(
 | 
				
			||||||
 | 
					  to_parse str: String,
 | 
				
			||||||
 | 
					  with opt_fn: fn(String) -> Result(#(String, String), Nil),
 | 
				
			||||||
 | 
					) -> #(String, String) {
 | 
				
			||||||
 | 
					  case opt_fn(str) {
 | 
				
			||||||
 | 
					    Error(Nil) -> #("", str)
 | 
				
			||||||
 | 
					    Ok(r) -> r
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_optional_result(
 | 
				
			||||||
 | 
					  to_parse str: String,
 | 
				
			||||||
 | 
					  with opt_fn: fn(String) -> Result(#(String, String), Nil),
 | 
				
			||||||
 | 
					) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 | 
					  parse_optional(str, opt_fn) |> Ok
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_this_then(
 | 
				
			||||||
 | 
					  to_parse str: String,
 | 
				
			||||||
 | 
					  with parsers: List(fn(String) -> Result(#(String, String), Nil)),
 | 
				
			||||||
 | 
					) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 | 
					  do_parse_this_then(str, "", parsers)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn do_parse_this_then(
 | 
				
			||||||
 | 
					  to_parse str: String,
 | 
				
			||||||
 | 
					  from initial: String,
 | 
				
			||||||
 | 
					  with parsers: List(fn(String) -> Result(#(String, String), Nil)),
 | 
				
			||||||
 | 
					) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 | 
					  case parsers {
 | 
				
			||||||
 | 
					    [] -> Ok(#(initial, str))
 | 
				
			||||||
 | 
					    [head, ..tail] -> {
 | 
				
			||||||
 | 
					      case head(str) {
 | 
				
			||||||
 | 
					        Ok(#(res, rest)) -> do_parse_this_then(rest, initial <> res, tail)
 | 
				
			||||||
 | 
					        Error(_) -> Error(Nil)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_multiple(
 | 
				
			||||||
 | 
					  to_parse str: String,
 | 
				
			||||||
 | 
					  with to_run: fn(String) -> Result(#(String, String), Nil),
 | 
				
			||||||
 | 
					) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 | 
					  case do_parse_multiple(str, to_run, "") {
 | 
				
			||||||
 | 
					    Ok(#("", _)) | Error(Nil) -> Error(Nil)
 | 
				
			||||||
 | 
					    Ok(#(r, rest)) -> Ok(#(r, rest))
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn do_parse_multiple(
 | 
				
			||||||
 | 
					  to_parse str: String,
 | 
				
			||||||
 | 
					  with to_run: fn(String) -> Result(#(String, String), Nil),
 | 
				
			||||||
 | 
					  acc ret: String,
 | 
				
			||||||
 | 
					) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 | 
					  case str {
 | 
				
			||||||
 | 
					    "" -> Ok(#(ret, str))
 | 
				
			||||||
 | 
					    _ ->
 | 
				
			||||||
 | 
					      case to_run(str) {
 | 
				
			||||||
 | 
					        Ok(#(r, rest)) -> do_parse_multiple(rest, to_run, ret <> r)
 | 
				
			||||||
 | 
					        Error(_) -> Ok(#(ret, str))
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn combine_uris(uris: List(Uri)) -> Uri {
 | 
				
			||||||
 | 
					  list.fold(uris, Uri(None, None, None, None, "", None, None), fn(acc, uri) {
 | 
				
			||||||
 | 
					    let acc = case uri {
 | 
				
			||||||
 | 
					      Uri(Some(scheme), _, _, _, _, _, _) -> Uri(..acc, scheme: Some(scheme))
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    let acc = case uri {
 | 
				
			||||||
 | 
					      Uri(_, Some(userinfo), _, _, _, _, _) ->
 | 
				
			||||||
 | 
					        Uri(..acc, userinfo: Some(userinfo))
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    let acc = case uri {
 | 
				
			||||||
 | 
					      Uri(_, _, Some(host), _, _, _, _) -> Uri(..acc, host: Some(host))
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    let acc = case uri {
 | 
				
			||||||
 | 
					      Uri(_, _, _, Some(port), _, _, _) -> Uri(..acc, port: Some(port))
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    let acc = case uri {
 | 
				
			||||||
 | 
					      Uri(_, _, _, _, path, _, _) if path != "" -> Uri(..acc, path: path)
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    let acc = case uri {
 | 
				
			||||||
 | 
					      Uri(_, _, _, _, _, Some(query), _) -> Uri(..acc, query: Some(query))
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    case uri {
 | 
				
			||||||
 | 
					      Uri(_, _, _, _, _, _, Some(fragment)) ->
 | 
				
			||||||
 | 
					        Uri(..acc, fragment: Some(fragment))
 | 
				
			||||||
 | 
					      _ -> acc
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn normalise(uri: Uri) -> Uri {
 | 
					pub fn normalise(uri: Uri) -> Uri {
 | 
				
			||||||
  let percent_splitter = splitter.new(["%"])
 | 
					  let percent_splitter = splitter.new(["%"])
 | 
				
			||||||
  let percent_normaliser = normalise_percent(percent_splitter, _)
 | 
					  let percent_normaliser = normalise_percent(percent_splitter, _)
 | 
				
			||||||
@@ -220,34 +370,70 @@ fn unescape_percent(str: String) -> String {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn parse_hex_digit(str) {
 | 
					@target(erlang)
 | 
				
			||||||
  case str {
 | 
					pub fn parse_hex_digit(str: String) -> Result(#(String, String), Nil) {
 | 
				
			||||||
    "0" as l <> rest
 | 
					  case string.pop_grapheme(str) {
 | 
				
			||||||
    | "1" as l <> rest
 | 
					    Ok(#("0" as char, tail))
 | 
				
			||||||
    | "2" as l <> rest
 | 
					    | Ok(#("1" as char, tail))
 | 
				
			||||||
    | "3" as l <> rest
 | 
					    | Ok(#("2" as char, tail))
 | 
				
			||||||
    | "4" as l <> rest
 | 
					    | Ok(#("3" as char, tail))
 | 
				
			||||||
    | "5" as l <> rest
 | 
					    | Ok(#("4" as char, tail))
 | 
				
			||||||
    | "6" as l <> rest
 | 
					    | Ok(#("5" as char, tail))
 | 
				
			||||||
    | "7" as l <> rest
 | 
					    | Ok(#("6" as char, tail))
 | 
				
			||||||
    | "8" as l <> rest
 | 
					    | Ok(#("7" as char, tail))
 | 
				
			||||||
    | "9" as l <> rest
 | 
					    | Ok(#("8" as char, tail))
 | 
				
			||||||
    | "a" as l <> rest
 | 
					    | Ok(#("9" as char, tail))
 | 
				
			||||||
    | "b" as l <> rest
 | 
					    | Ok(#("a" as char, tail))
 | 
				
			||||||
    | "c" as l <> rest
 | 
					    | Ok(#("b" as char, tail))
 | 
				
			||||||
    | "d" as l <> rest
 | 
					    | Ok(#("c" as char, tail))
 | 
				
			||||||
    | "e" as l <> rest
 | 
					    | Ok(#("d" as char, tail))
 | 
				
			||||||
    | "f" as l <> rest
 | 
					    | Ok(#("e" as char, tail))
 | 
				
			||||||
    | "A" as l <> rest
 | 
					    | Ok(#("f" as char, tail))
 | 
				
			||||||
    | "B" as l <> rest
 | 
					    | Ok(#("A" as char, tail))
 | 
				
			||||||
    | "C" as l <> rest
 | 
					    | Ok(#("B" as char, tail))
 | 
				
			||||||
    | "D" as l <> rest
 | 
					    | Ok(#("C" as char, tail))
 | 
				
			||||||
    | "E" as l <> rest
 | 
					    | Ok(#("D" as char, tail))
 | 
				
			||||||
    | "F" as l <> rest -> Ok(#(l, rest))
 | 
					    | Ok(#("E" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("F" as char, tail)) -> Ok(#(char, tail))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _ -> Error(Nil)
 | 
					    _ -> Error(Nil)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@target(javascript)
 | 
				
			||||||
 | 
					pub fn parse_hex_digit(str: String) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 | 
					  case str {
 | 
				
			||||||
 | 
					    "0" as char <> tail
 | 
				
			||||||
 | 
					    | "1" as char <> tail
 | 
				
			||||||
 | 
					    | "2" as char <> tail
 | 
				
			||||||
 | 
					    | "3" as char <> tail
 | 
				
			||||||
 | 
					    | "4" as char <> tail
 | 
				
			||||||
 | 
					    | "5" as char <> tail
 | 
				
			||||||
 | 
					    | "6" as char <> tail
 | 
				
			||||||
 | 
					    | "7" as char <> tail
 | 
				
			||||||
 | 
					    | "8" as char <> tail
 | 
				
			||||||
 | 
					    | "9" as char <> tail
 | 
				
			||||||
 | 
					    | "a" as char <> tail
 | 
				
			||||||
 | 
					    | "b" as char <> tail
 | 
				
			||||||
 | 
					    | "c" as char <> tail
 | 
				
			||||||
 | 
					    | "d" as char <> tail
 | 
				
			||||||
 | 
					    | "e" as char <> tail
 | 
				
			||||||
 | 
					    | "f" as char <> tail
 | 
				
			||||||
 | 
					    | "A" as char <> tail
 | 
				
			||||||
 | 
					    | "B" as char <> tail
 | 
				
			||||||
 | 
					    | "C" as char <> tail
 | 
				
			||||||
 | 
					    | "D" as char <> tail
 | 
				
			||||||
 | 
					    | "E" as char <> tail
 | 
				
			||||||
 | 
					    | "F" as char <> tail -> Ok(#(char, tail))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _ -> Error(Nil)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_hex_digits(str, min, max) {
 | 
				
			||||||
 | 
					  parse_min_max(str, min, max, parse_hex_digit)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn encoding_not_needed(i: Int) -> Bool {
 | 
					fn encoding_not_needed(i: Int) -> Bool {
 | 
				
			||||||
  // $-_.+!*'()
 | 
					  // $-_.+!*'()
 | 
				
			||||||
  case i {
 | 
					  case i {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										359
									
								
								test/benchmark.gleam
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										359
									
								
								test/benchmark.gleam
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,359 @@
 | 
				
			|||||||
 | 
					import gleam/string
 | 
				
			||||||
 | 
					import gleam/uri as uri2
 | 
				
			||||||
 | 
					import gluri as uri
 | 
				
			||||||
 | 
					import glychee/benchmark
 | 
				
			||||||
 | 
					import glychee/configuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@target(erlang)
 | 
				
			||||||
 | 
					pub fn main() {
 | 
				
			||||||
 | 
					  configuration.initialize()
 | 
				
			||||||
 | 
					  configuration.set_pair(configuration.Warmup, 2)
 | 
				
			||||||
 | 
					  configuration.set_pair(configuration.Parallel, 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // pop_benchmark()
 | 
				
			||||||
 | 
					  parse_benchmark()
 | 
				
			||||||
 | 
					  // reg_name_benchmark()
 | 
				
			||||||
 | 
					  // ip_benchmark()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// @target(erlang)
 | 
				
			||||||
 | 
					// pub fn ip_benchmark() {
 | 
				
			||||||
 | 
					//   benchmark.run(
 | 
				
			||||||
 | 
					//     [
 | 
				
			||||||
 | 
					//       benchmark.Function("ip_benchmark", fn(data) {
 | 
				
			||||||
 | 
					//         fn() {
 | 
				
			||||||
 | 
					//           let _ = parser.parse_dec_octet(data)
 | 
				
			||||||
 | 
					//           Nil
 | 
				
			||||||
 | 
					//         }
 | 
				
			||||||
 | 
					//       }),
 | 
				
			||||||
 | 
					//     ],
 | 
				
			||||||
 | 
					//     [
 | 
				
			||||||
 | 
					//       benchmark.Data("173", "173"),
 | 
				
			||||||
 | 
					//       benchmark.Data("5", "5"),
 | 
				
			||||||
 | 
					//       benchmark.Data("200", "200"),
 | 
				
			||||||
 | 
					//       benchmark.Data("255", "255"),
 | 
				
			||||||
 | 
					//       benchmark.Data("fail", "2b"),
 | 
				
			||||||
 | 
					//     ],
 | 
				
			||||||
 | 
					//   )
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// @target(erlang)
 | 
				
			||||||
 | 
					// pub fn reg_name_benchmark() {
 | 
				
			||||||
 | 
					//   benchmark.run(
 | 
				
			||||||
 | 
					//     [
 | 
				
			||||||
 | 
					//       benchmark.Function("reg_name_benchmark", fn(data) {
 | 
				
			||||||
 | 
					//         fn() {
 | 
				
			||||||
 | 
					//           let _ = parser.parse_reg_name(data)
 | 
				
			||||||
 | 
					//           Nil
 | 
				
			||||||
 | 
					//         }
 | 
				
			||||||
 | 
					//       }),
 | 
				
			||||||
 | 
					//     ],
 | 
				
			||||||
 | 
					//     [
 | 
				
			||||||
 | 
					//       benchmark.Data("long", "github.com"),
 | 
				
			||||||
 | 
					//     ],
 | 
				
			||||||
 | 
					//   )
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@target(erlang)
 | 
				
			||||||
 | 
					pub fn parse_benchmark() {
 | 
				
			||||||
 | 
					  benchmark.run(
 | 
				
			||||||
 | 
					    [
 | 
				
			||||||
 | 
					      benchmark.Function("parse_benchmark", fn(data) {
 | 
				
			||||||
 | 
					        fn() {
 | 
				
			||||||
 | 
					          let _ = uri.parse(data)
 | 
				
			||||||
 | 
					          Nil
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }),
 | 
				
			||||||
 | 
					      benchmark.Function("stdlib_parse_benchmark", fn(data) {
 | 
				
			||||||
 | 
					        fn() {
 | 
				
			||||||
 | 
					          let _ = uri2.parse(data)
 | 
				
			||||||
 | 
					          Nil
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    [
 | 
				
			||||||
 | 
					      benchmark.Data(
 | 
				
			||||||
 | 
					        "long",
 | 
				
			||||||
 | 
					        "https://github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					      benchmark.Data(
 | 
				
			||||||
 | 
					        "with user",
 | 
				
			||||||
 | 
					        "https://test_name:user%20$$$@github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					      benchmark.Data("ipv4", "https://192.255.36.4/"),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@target(erlang)
 | 
				
			||||||
 | 
					pub fn pop_benchmark() {
 | 
				
			||||||
 | 
					  benchmark.run(
 | 
				
			||||||
 | 
					    [
 | 
				
			||||||
 | 
					      benchmark.Function("pop", fn(data) { fn() { pop(data, "") } }),
 | 
				
			||||||
 | 
					      benchmark.Function("pop2", fn(data) { fn() { pop4(data, "") } }),
 | 
				
			||||||
 | 
					      benchmark.Function("pop3", fn(data) { fn() { pop5(data, "") } }),
 | 
				
			||||||
 | 
					      benchmark.Function("match", fn(data) { fn() { pop2(data, "") } }),
 | 
				
			||||||
 | 
					      benchmark.Function("match_2", fn(data) { fn() { pop3(data, "") } }),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    [
 | 
				
			||||||
 | 
					      // benchmark.Data("long", "abcdefghijklmnopqrstuvwxyz"),
 | 
				
			||||||
 | 
					      benchmark.Data(
 | 
				
			||||||
 | 
					        "with user",
 | 
				
			||||||
 | 
					        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					      // benchmark.Data("ipv4", "https://192.255.36.4/"),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn pop(input, _) {
 | 
				
			||||||
 | 
					  case string.pop_grapheme(input) {
 | 
				
			||||||
 | 
					    Ok(#(char, tail)) -> {
 | 
				
			||||||
 | 
					      let assert [codepoint] = string.to_utf_codepoints(char)
 | 
				
			||||||
 | 
					      let i = string.utf_codepoint_to_int(codepoint)
 | 
				
			||||||
 | 
					      case i {
 | 
				
			||||||
 | 
					        _ if i >= 0x41 && i <= 0x5A -> pop(tail, char)
 | 
				
			||||||
 | 
					        _ if i >= 0x61 && i <= 0x7A -> pop(tail, char)
 | 
				
			||||||
 | 
					        _ -> Nil
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    Error(_) -> Nil
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn pop2(input, _) {
 | 
				
			||||||
 | 
					  case input {
 | 
				
			||||||
 | 
					    "a" as j <> tail
 | 
				
			||||||
 | 
					    | "b" as j <> tail
 | 
				
			||||||
 | 
					    | "c" as j <> tail
 | 
				
			||||||
 | 
					    | "d" as j <> tail
 | 
				
			||||||
 | 
					    | "e" as j <> tail
 | 
				
			||||||
 | 
					    | "f" as j <> tail
 | 
				
			||||||
 | 
					    | "g" as j <> tail
 | 
				
			||||||
 | 
					    | "h" as j <> tail
 | 
				
			||||||
 | 
					    | "i" as j <> tail
 | 
				
			||||||
 | 
					    | "j" as j <> tail
 | 
				
			||||||
 | 
					    | "k" as j <> tail
 | 
				
			||||||
 | 
					    | "l" as j <> tail
 | 
				
			||||||
 | 
					    | "m" as j <> tail
 | 
				
			||||||
 | 
					    | "n" as j <> tail
 | 
				
			||||||
 | 
					    | "o" as j <> tail
 | 
				
			||||||
 | 
					    | "p" as j <> tail
 | 
				
			||||||
 | 
					    | "q" as j <> tail
 | 
				
			||||||
 | 
					    | "r" as j <> tail
 | 
				
			||||||
 | 
					    | "s" as j <> tail
 | 
				
			||||||
 | 
					    | "t" as j <> tail
 | 
				
			||||||
 | 
					    | "u" as j <> tail
 | 
				
			||||||
 | 
					    | "v" as j <> tail
 | 
				
			||||||
 | 
					    | "w" as j <> tail
 | 
				
			||||||
 | 
					    | "x" as j <> tail
 | 
				
			||||||
 | 
					    | "y" as j <> tail
 | 
				
			||||||
 | 
					    | "z" as j <> tail
 | 
				
			||||||
 | 
					    | "A" as j <> tail
 | 
				
			||||||
 | 
					    | "B" as j <> tail
 | 
				
			||||||
 | 
					    | "C" as j <> tail
 | 
				
			||||||
 | 
					    | "D" as j <> tail
 | 
				
			||||||
 | 
					    | "E" as j <> tail
 | 
				
			||||||
 | 
					    | "F" as j <> tail
 | 
				
			||||||
 | 
					    | "G" as j <> tail
 | 
				
			||||||
 | 
					    | "H" as j <> tail
 | 
				
			||||||
 | 
					    | "I" as j <> tail
 | 
				
			||||||
 | 
					    | "J" as j <> tail
 | 
				
			||||||
 | 
					    | "K" as j <> tail
 | 
				
			||||||
 | 
					    | "L" as j <> tail
 | 
				
			||||||
 | 
					    | "M" as j <> tail
 | 
				
			||||||
 | 
					    | "N" as j <> tail
 | 
				
			||||||
 | 
					    | "O" as j <> tail
 | 
				
			||||||
 | 
					    | "P" as j <> tail
 | 
				
			||||||
 | 
					    | "Q" as j <> tail
 | 
				
			||||||
 | 
					    | "R" as j <> tail
 | 
				
			||||||
 | 
					    | "S" as j <> tail
 | 
				
			||||||
 | 
					    | "T" as j <> tail
 | 
				
			||||||
 | 
					    | "U" as j <> tail
 | 
				
			||||||
 | 
					    | "V" as j <> tail
 | 
				
			||||||
 | 
					    | "W" as j <> tail
 | 
				
			||||||
 | 
					    | "X" as j <> tail
 | 
				
			||||||
 | 
					    | "Y" as j <> tail
 | 
				
			||||||
 | 
					    | "Z" as j <> tail -> pop2(tail, j)
 | 
				
			||||||
 | 
					    _ -> Nil
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn pop3(input, _) {
 | 
				
			||||||
 | 
					  case input {
 | 
				
			||||||
 | 
					    "a" <> tail
 | 
				
			||||||
 | 
					    | "b" <> tail
 | 
				
			||||||
 | 
					    | "c" <> tail
 | 
				
			||||||
 | 
					    | "d" <> tail
 | 
				
			||||||
 | 
					    | "e" <> tail
 | 
				
			||||||
 | 
					    | "f" <> tail
 | 
				
			||||||
 | 
					    | "g" <> tail
 | 
				
			||||||
 | 
					    | "h" <> tail
 | 
				
			||||||
 | 
					    | "i" <> tail
 | 
				
			||||||
 | 
					    | "j" <> tail
 | 
				
			||||||
 | 
					    | "k" <> tail
 | 
				
			||||||
 | 
					    | "l" <> tail
 | 
				
			||||||
 | 
					    | "m" <> tail
 | 
				
			||||||
 | 
					    | "n" <> tail
 | 
				
			||||||
 | 
					    | "o" <> tail
 | 
				
			||||||
 | 
					    | "p" <> tail
 | 
				
			||||||
 | 
					    | "q" <> tail
 | 
				
			||||||
 | 
					    | "r" <> tail
 | 
				
			||||||
 | 
					    | "s" <> tail
 | 
				
			||||||
 | 
					    | "t" <> tail
 | 
				
			||||||
 | 
					    | "u" <> tail
 | 
				
			||||||
 | 
					    | "v" <> tail
 | 
				
			||||||
 | 
					    | "w" <> tail
 | 
				
			||||||
 | 
					    | "x" <> tail
 | 
				
			||||||
 | 
					    | "y" <> tail
 | 
				
			||||||
 | 
					    | "z" <> tail
 | 
				
			||||||
 | 
					    | "A" <> tail
 | 
				
			||||||
 | 
					    | "B" <> tail
 | 
				
			||||||
 | 
					    | "C" <> tail
 | 
				
			||||||
 | 
					    | "D" <> tail
 | 
				
			||||||
 | 
					    | "E" <> tail
 | 
				
			||||||
 | 
					    | "F" <> tail
 | 
				
			||||||
 | 
					    | "G" <> tail
 | 
				
			||||||
 | 
					    | "H" <> tail
 | 
				
			||||||
 | 
					    | "I" <> tail
 | 
				
			||||||
 | 
					    | "J" <> tail
 | 
				
			||||||
 | 
					    | "K" <> tail
 | 
				
			||||||
 | 
					    | "L" <> tail
 | 
				
			||||||
 | 
					    | "M" <> tail
 | 
				
			||||||
 | 
					    | "N" <> tail
 | 
				
			||||||
 | 
					    | "O" <> tail
 | 
				
			||||||
 | 
					    | "P" <> tail
 | 
				
			||||||
 | 
					    | "Q" <> tail
 | 
				
			||||||
 | 
					    | "R" <> tail
 | 
				
			||||||
 | 
					    | "S" <> tail
 | 
				
			||||||
 | 
					    | "T" <> tail
 | 
				
			||||||
 | 
					    | "U" <> tail
 | 
				
			||||||
 | 
					    | "V" <> tail
 | 
				
			||||||
 | 
					    | "W" <> tail
 | 
				
			||||||
 | 
					    | "X" <> tail
 | 
				
			||||||
 | 
					    | "Y" <> tail
 | 
				
			||||||
 | 
					    | "Z" <> tail -> pop3(tail, "")
 | 
				
			||||||
 | 
					    _ -> Nil
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn pop4(input, _) {
 | 
				
			||||||
 | 
					  case string.pop_grapheme(input) {
 | 
				
			||||||
 | 
					    Ok(#(char, tail)) -> {
 | 
				
			||||||
 | 
					      case char {
 | 
				
			||||||
 | 
					        "a"
 | 
				
			||||||
 | 
					        | "b"
 | 
				
			||||||
 | 
					        | "c"
 | 
				
			||||||
 | 
					        | "d"
 | 
				
			||||||
 | 
					        | "e"
 | 
				
			||||||
 | 
					        | "f"
 | 
				
			||||||
 | 
					        | "g"
 | 
				
			||||||
 | 
					        | "h"
 | 
				
			||||||
 | 
					        | "i"
 | 
				
			||||||
 | 
					        | "j"
 | 
				
			||||||
 | 
					        | "k"
 | 
				
			||||||
 | 
					        | "l"
 | 
				
			||||||
 | 
					        | "m"
 | 
				
			||||||
 | 
					        | "n"
 | 
				
			||||||
 | 
					        | "o"
 | 
				
			||||||
 | 
					        | "p"
 | 
				
			||||||
 | 
					        | "q"
 | 
				
			||||||
 | 
					        | "r"
 | 
				
			||||||
 | 
					        | "s"
 | 
				
			||||||
 | 
					        | "t"
 | 
				
			||||||
 | 
					        | "u"
 | 
				
			||||||
 | 
					        | "v"
 | 
				
			||||||
 | 
					        | "w"
 | 
				
			||||||
 | 
					        | "x"
 | 
				
			||||||
 | 
					        | "y"
 | 
				
			||||||
 | 
					        | "z"
 | 
				
			||||||
 | 
					        | "A"
 | 
				
			||||||
 | 
					        | "B"
 | 
				
			||||||
 | 
					        | "C"
 | 
				
			||||||
 | 
					        | "D"
 | 
				
			||||||
 | 
					        | "E"
 | 
				
			||||||
 | 
					        | "F"
 | 
				
			||||||
 | 
					        | "G"
 | 
				
			||||||
 | 
					        | "H"
 | 
				
			||||||
 | 
					        | "I"
 | 
				
			||||||
 | 
					        | "J"
 | 
				
			||||||
 | 
					        | "K"
 | 
				
			||||||
 | 
					        | "L"
 | 
				
			||||||
 | 
					        | "M"
 | 
				
			||||||
 | 
					        | "N"
 | 
				
			||||||
 | 
					        | "O"
 | 
				
			||||||
 | 
					        | "P"
 | 
				
			||||||
 | 
					        | "Q"
 | 
				
			||||||
 | 
					        | "R"
 | 
				
			||||||
 | 
					        | "S"
 | 
				
			||||||
 | 
					        | "T"
 | 
				
			||||||
 | 
					        | "U"
 | 
				
			||||||
 | 
					        | "V"
 | 
				
			||||||
 | 
					        | "W"
 | 
				
			||||||
 | 
					        | "X"
 | 
				
			||||||
 | 
					        | "Y"
 | 
				
			||||||
 | 
					        | "Z" -> pop4(tail, char)
 | 
				
			||||||
 | 
					        _ -> Nil
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    Error(_) -> Nil
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn pop5(input, _) {
 | 
				
			||||||
 | 
					  case string.pop_grapheme(input) {
 | 
				
			||||||
 | 
					    Ok(#("a" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("b" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("c" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("d" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("e" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("f" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("g" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("h" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("i" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("j" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("k" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("l" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("m" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("n" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("o" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("p" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("q" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("r" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("s" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("t" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("u" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("v" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("w" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("x" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("y" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("z" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("A" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("B" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("C" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("D" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("E" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("F" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("G" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("H" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("I" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("J" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("K" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("L" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("M" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("N" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("O" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("P" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("Q" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("R" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("S" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("T" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("U" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("V" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("W" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("X" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("Y" as char, tail))
 | 
				
			||||||
 | 
					    | Ok(#("Z" as char, tail)) -> pop4(tail, char)
 | 
				
			||||||
 | 
					    _ -> Nil
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										16
									
								
								test/benchmark.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								test/benchmark.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					import { run, bench, boxplot, summary } from "mitata";
 | 
				
			||||||
 | 
					import { parse } from "../build/dev/javascript/gluri/gluri.mjs";
 | 
				
			||||||
 | 
					import { parse as parse2 } from "../build/dev/javascript/gleam_stdlib/gleam/uri.mjs";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bench("parse", () =>
 | 
				
			||||||
 | 
					  parse(
 | 
				
			||||||
 | 
					    "https://test_name:user%20$$$@github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
 | 
					  ),
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					bench("parse2", () =>
 | 
				
			||||||
 | 
					  parse2(
 | 
				
			||||||
 | 
					    "https://test_name:user%20$$$@github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
 | 
					  ),
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					await run();
 | 
				
			||||||
@@ -9,6 +9,66 @@ pub fn main() {
 | 
				
			|||||||
  startest.run(startest.default_config())
 | 
					  startest.run(startest.default_config())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_general_tests() {
 | 
				
			||||||
 | 
					  describe("general parsing", [
 | 
				
			||||||
 | 
					    it("mailto parsing", fn() {
 | 
				
			||||||
 | 
					      uri.parse("mailto:Joe@example.com")
 | 
				
			||||||
 | 
					      |> should.equal(Ok(
 | 
				
			||||||
 | 
					        Uri(..empty, scheme: Some("mailto"), path: "Joe@example.com"),
 | 
				
			||||||
 | 
					      ))
 | 
				
			||||||
 | 
					      uri.parse("mailto:Joe@example.com?hello#bye")
 | 
				
			||||||
 | 
					      |> should.equal(Ok(
 | 
				
			||||||
 | 
					        Uri(
 | 
				
			||||||
 | 
					          ..empty,
 | 
				
			||||||
 | 
					          scheme: Some("mailto"),
 | 
				
			||||||
 | 
					          path: "Joe@example.com",
 | 
				
			||||||
 | 
					          query: Some("hello"),
 | 
				
			||||||
 | 
					          fragment: Some("bye"),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					      ))
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
 | 
					    it("ai gen pass", fn() {
 | 
				
			||||||
 | 
					      let _ = uri.parse("https://example.com") |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse("http://www.example.org/resource?id=123&lang=en")
 | 
				
			||||||
 | 
					        |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse("ftp://ftp.example.net/pub/files/archive.tar.gz")
 | 
				
			||||||
 | 
					        |> should.be_ok
 | 
				
			||||||
 | 
					      let _ = uri.parse("mailto:user+alias@example.com") |> should.be_ok
 | 
				
			||||||
 | 
					      let _ = uri.parse("urn:isbn:978-3-16-148410-0") |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse("ws://socket.example.com:8080/chat?room=42#section2")
 | 
				
			||||||
 | 
					        |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse("https://sub.domain.co.uk/path/to/resource/") |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse("file:///C:/Windows/System32/drivers/etc/hosts")
 | 
				
			||||||
 | 
					        |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse("git+ssh://git@example.com:2222/repo.git") |> should.be_ok
 | 
				
			||||||
 | 
					      let _ =
 | 
				
			||||||
 | 
					        uri.parse(
 | 
				
			||||||
 | 
					          "https://xn--fsqu00a.xn--0zwm56d/%E8%B7%AF%E5%BE%84?%E6%9F%A5%E8%AF%A2=%E5%80%BC#%E7%89%87%E6%AE%B5",
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        |> should.be_ok
 | 
				
			||||||
 | 
					      Nil
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
 | 
					    it("ai gen fail", fn() {
 | 
				
			||||||
 | 
					      let _ = uri.parse("ht!tp://example.com") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://exa mple.com") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("://missing-scheme.com") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://example.com:80a/") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://[2001:db8::1") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://example.com/%ZZ") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://example.com?%") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("`https://example.com/invalid") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://example.com?foo=bar%2") |> should.be_error
 | 
				
			||||||
 | 
					      let _ = uri.parse("http://example.com:12345abc/") |> should.be_error
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
 | 
					  ])
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn parse_scheme_tests() {
 | 
					pub fn parse_scheme_tests() {
 | 
				
			||||||
  describe("scheme parsing", [
 | 
					  describe("scheme parsing", [
 | 
				
			||||||
    it("simple parse", fn() {
 | 
					    it("simple parse", fn() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,20 @@
 | 
				
			|||||||
// import gleam/result
 | 
					// import gleam/result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// import gleam/uri as uri2
 | 
					import gleam/uri as uri2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// import splitter
 | 
					// import splitter
 | 
				
			||||||
// import types.{Uri}
 | 
					// import types.{Uri}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import gluri as uri
 | 
					import gluri as uri
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn main() {
 | 
					pub fn main() {
 | 
				
			||||||
  uri.parse("http://my_host.com") |> echo
 | 
					  // uri.parse("https://192.255.36.4/") |> echo
 | 
				
			||||||
 | 
					  // uri.parse(
 | 
				
			||||||
 | 
					  //   "https://github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
 | 
					  // )
 | 
				
			||||||
 | 
					  // |> echo
 | 
				
			||||||
 | 
					  let _ = uri.parse("/abc/def") |> echo
 | 
				
			||||||
 | 
					  let _ = uri2.parse("/abc/def") |> echo
 | 
				
			||||||
 | 
					  let _ = uri.parse("/abc/") |> echo
 | 
				
			||||||
  Nil
 | 
					  Nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								uri.abnf
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								uri.abnf
									
									
									
									
									
								
							@@ -90,5 +90,3 @@ RFC 3986                   URI Generic Syntax               January 2005
 | 
				
			|||||||
   gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
 | 
					   gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
 | 
				
			||||||
   sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
 | 
					   sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
 | 
				
			||||||
                 / "*" / "+" / "," / ";" / "="
 | 
					                 / "*" / "+" / "," / ";" / "="
 | 
				
			||||||
                 
 | 
					 | 
				
			||||||
                 " # % < > [ \ ] ^ ` { | }
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user