-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<input type="text" id="uri" placeholder="Enter a URI here" style="width:100%; box-sizing:border-box;"><br> | ||
<button id="parse_scheme" style="clear:left;">Parse according to scheme</button> | ||
<button id="parse_generic">Parse as a generic URI</button><br> | ||
<br> | ||
<input type="text" id="email" placeholder="Enter an email address here" style="width:100%; box-sizing:border-box;"><br> | ||
<button id="parse_mailbox">Parse email address</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import URI, {isDNSDomain, parseMailbox} from "https://cdn.jsdelivr.net/gh/wizard04wsu/URI_Parsing@jsfiddle-demo/src/uri_parsing.mjs" | ||
|
||
document.getElementById("parse_scheme").addEventListener("click", ()=>{ | ||
let val = document.getElementById("uri").value; | ||
console.group("scheme"); | ||
try{ | ||
let obj = URI(val); | ||
console.log("--> "+obj.toString()); | ||
console.log(obj); | ||
}catch(e){ | ||
if(e instanceof URIError) console.error(e.message); | ||
else throw e; | ||
}finally{ | ||
console.groupEnd(); | ||
} | ||
}, false); | ||
|
||
document.getElementById("parse_generic").addEventListener("click", ()=>{ | ||
let val = document.getElementById("uri").value; | ||
console.group("generic"); | ||
try{ | ||
let obj = URI.parse(val) | ||
console.log("--> "+obj.toString()); | ||
console.log(obj); | ||
}catch(e){ | ||
if(e instanceof URIError) console.error(e.message); | ||
else throw e; | ||
}finally{ | ||
console.groupEnd(); | ||
} | ||
}, false); | ||
|
||
document.getElementById("parse_mailbox").addEventListener("click", ()=>{ | ||
let val = document.getElementById("email").value; | ||
console.group("email"); | ||
try{ | ||
let obj = parseMailbox(val); | ||
console.log("--> "+obj.toString()); | ||
console.log(obj); | ||
}catch(e){ | ||
if(e instanceof URIError) console.log(e.message); | ||
else throw e; | ||
}finally{ | ||
console.groupEnd(); | ||
} | ||
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters