-
Notifications
You must be signed in to change notification settings - Fork 3
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
Universal Web
committed
Oct 3, 2023
1 parent
0173847
commit 0ce5ae6
Showing
4 changed files
with
103 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,43 @@ | ||
import { jsonParse } from '@universalweb/acid'; | ||
class UWRL { | ||
constructor(urlOriginal, paramaters) { | ||
let url = urlOriginal; | ||
if (paramaters) { | ||
this.paramaters = paramaters; | ||
} | ||
if (url.includes('{')) { | ||
const urlParts = urlOriginal.split('{'); | ||
url = urlParts[0]; | ||
try { | ||
this.paramaters = jsonParse(`{${urlParts[1]}`); | ||
if (paramaters) { | ||
if (paramaters['#']) { | ||
this.hash = paramaters['#']; | ||
} | ||
} | ||
} catch { | ||
this.paramaters = {}; | ||
} | ||
} | ||
this.href = url; | ||
} | ||
get search() { | ||
return this.paramaterString; | ||
} | ||
get searchParams() { | ||
return this.parameters; | ||
} | ||
hash = ''; | ||
isUWRI = true; | ||
} | ||
// Supports Username Password and URL Fragments | ||
// Server can opt in to get the URL fragments | ||
// fragments are turned into client side state tracking | ||
const uwri = new UWRL('https://www.example.com:8080/path/to/resource{"query":"value", "#": "fragment also known as on the UW as state", ":": ["username", "password"]}'); | ||
console.log(uwri); | ||
const uwri2 = new UWRL('https://www.example.com:8080/path/to/resource', { | ||
query: 'value', | ||
'#': 'fragment', | ||
'@': ['username', 'password'] | ||
}); | ||
console.log(uwri2); |
File renamed without changes.
Empty file.