diff --git a/main.go b/main.go
index b3b23f3..a977eaa 100644
--- a/main.go
+++ b/main.go
@@ -30,6 +30,7 @@ type ShortLinks struct {
type setResponse struct {
Short string `json:"short"`
Domain string `json:"domain"`
+ URL string `json:"url"`
}
type suggestResponse struct {
@@ -188,6 +189,7 @@ func (sl *ShortLinks) serveSet(w http.ResponseWriter, r *http.Request) {
sendJSON(w, setResponse{
Short: short,
Domain: sl.getDomain(r.Host),
+ URL: fmt.Sprintf("https://%s/%s", sl.getDomain(r.Host), short),
})
}
diff --git a/static/help.html b/static/help.html
index 4dad6ea..e8b1ab0 100644
--- a/static/help.html
+++ b/static/help.html
@@ -94,49 +94,14 @@ sl-tag::part(base) {
Get
Value
for
- short
+ url
in
Contents of URL
-
- Set variable
- short
- to
- Dictionary Value
-
-
-
- Get
- Value
- for
- domain
- in
- Contents of URL
-
-
-
- Set variable
- domain
- to
- Dictionary Value
-
-
-
- Combine
- https://
- domain
- /
- short
- +
- with
- Custom
- Text
-
-
Share
- Combined Text
+ Dictionary Value
Type:
URL
@@ -186,49 +151,14 @@ sl-tag::part(base) {
Get
Value
for
- short
+ url
in
Contents of URL
-
- Set variable
- short
- to
- Dictionary Value
-
-
-
- Get
- Value
- for
- domain
- in
- Contents of URL
-
-
-
- Set variable
- domain
- to
- Dictionary Value
-
-
-
- Combine
- https://
- domain
- /
- short
- +
- with
- Custom
- Text
-
-
Copy
- Combined Text
+ Dictionary Value
to clipboard
Type:
diff --git a/static/index.html b/static/index.html
index d983447..4ac6ef3 100644
--- a/static/index.html
+++ b/static/index.html
@@ -142,9 +142,9 @@ async function set(short, long) {
const data = await resp.json();
const newShort = data.short;
- const newDomain = data.domain;
+ const newURL = data.url;
- setShortItem(newShort, newDomain, 'check-square');
+ setShortItem(newShort, newURL, 'check-square');
// Only set the icons if we were actually setting from these inputs
if (document.getElementById('short').value == short && document.getElementById('long').value == long) {
@@ -155,7 +155,7 @@ async function set(short, long) {
// Only set the clipboard if the user didn't change the inputs
if (document.getElementById('short').value == oldShort && document.getElementById('long').value == oldLong) {
try {
- await navigator.clipboard.writeText(`${window.location.protocol}//${newDomain}/${newShort}`);
+ await navigator.clipboard.writeText(newURL);
} catch (err) {
console.log(err);
}
@@ -190,7 +190,7 @@ async function set(short, long) {
}
}
-function setShortItem(short, domain, icon) {
+function setShortItem(short, url, icon) {
const tree = document.getElementById('tree');
for (const item of tree.children) {
@@ -203,9 +203,9 @@ function setShortItem(short, domain, icon) {
item.appendChild(document.createElement('sl-icon')).setAttribute('name', icon);
item.appendChild(document.createTextNode(short));
- if (domain != null) {
+ if (url != null) {
item.addEventListener('click', () => {
- navigator.clipboard.writeText(`${window.location.protocol}//${domain}/${short}`);
+ navigator.clipboard.writeText(url);
});
}