Skip to content

Commit

Permalink
Standarizing UWRL / UWRI Formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal Web committed Oct 3, 2023
1 parent 0173847 commit 0ce5ae6
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 60 deletions.
120 changes: 60 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions udsp/UWRL/index.js
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 removed udsp/uwri/index.js
Empty file.

0 comments on commit 0ce5ae6

Please sign in to comment.