REBOL [
Title: "URI"
Date: 3-Jul-2002
Name: URI
Version: 1.0.0
File: %URI.r
Author: "Andrew Martin"
Needs: [%Common%20Parse%20Values.r]
Purpose: "URI parse rules."
Email: Al.Bri@xtra.co.nz
Web: http://valley.150m.com
Category: [util net text 5]
]
make object! [
Char: union AlphaDigit charset "-_~+*'"
Escape: [#"%" Hex Hex]
Chars: [some [Char | Escape]]
User: [some [Char | Escape | #"."]]
Domain-Label: Chars
Domain: [Domain-Label any [#"." Domain-Label]]
IP-Address: [Digits #"." Digits #"." Digits #"." Digits]
Host: [Domain | IP-Address]
eMail: [User #"@" Host]
Pass: Chars
Port: [1 4 Digit]
User-Pass-Host-Port: [
[User #":" Pass #"@" Host #":" Port]
| [User #":" Pass #"@" Host]
| [User #":" Host]
| [Host #":" Port]
| [Host]
]
Fragment: [#"#" Chars]
Query: [some [#"?" any [Chars #"=" Chars | Chars]]]
Fragment_Or_Query: [Fragment | Query]
Extension: [#"." 1 4 Chars]
File: [Chars opt [#"." Chars]]
Path: [some ["../" | "./" | [File #"/"]]]
Relative-Path: [
Path opt File opt Extension opt Fragment_Or_Query
| opt Path File opt Extension opt Fragment_Or_Query
| opt Path opt File Extension opt Fragment_Or_Query
| opt Path opt File opt Extension Fragment_Or_Query
]
Absolute-Path: [#"/" opt Relative-Path]
Net-Path: ["//" User-Pass-Host-Port opt [Absolute-Path]]
Scheme: [Alpha some Char]
URL: [Scheme #":" Net-Path]
Local-File: [#"%" [Absolute-Path | Relative-Path]]
set 'URI [eMail | URL | Local-File]
]