diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/main.ts | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -76,11 +76,15 @@ const settings = new KeyValueStore({ | |||
76 | locationPrefixEls[i].addEventListener('click', e => { | 76 | locationPrefixEls[i].addEventListener('click', e => { |
77 | e.preventDefault(); | 77 | e.preventDefault(); |
78 | 78 | ||
79 | let resp = prompt('Please enter new location: ', ''); | 79 | let resp = prompt('Please enter new location (gopher://... or gemini://...):', ''); |
80 | if ((resp !== null) && (resp.trim() !== "")) { | 80 | if ((resp !== null) && (resp.trim() !== "")) { |
81 | resp = resp.trim(); | 81 | resp = resp.trim(); |
82 | if (resp.indexOf('gopher://') === 0) { | 82 | if (resp.indexOf('gopher://') === 0) { |
83 | resp = resp.substring(9); | 83 | resp = 'gopher/' + resp.substring(9); |
84 | } else if (resp.indexOf('gemini://') === 0) { | ||
85 | resp = 'gemini/' + resp.substring(9); | ||
86 | } else { | ||
87 | resp = 'gopher/' + resp; | ||
84 | } | 88 | } |
85 | 89 | ||
86 | window.location.href = window.location.origin + '/' + resp; | 90 | window.location.href = window.location.origin + '/' + resp; |
@@ -305,7 +309,9 @@ function generateMarkupForPlainLinks() { | |||
305 | contentEl.innerHTML = contentEl.innerHTML.replace(urlRegex, match => { | 309 | contentEl.innerHTML = contentEl.innerHTML.replace(urlRegex, match => { |
306 | let href: string = match; | 310 | let href: string = match; |
307 | if (href.indexOf('gopher://') === 0) { | 311 | if (href.indexOf('gopher://') === 0) { |
308 | href = href.replace(/^gopher:\/\/(.*)$/, location.origin + '/$1'); | 312 | href = href.replace(/^gopher:\/\/(.*)$/, location.origin + '/gopher/$1'); |
313 | } else if (href.indexOf('gemini://') === 0) { | ||
314 | href = href.replace(/^gemini:\/\/(.*)$/, location.origin + '/gemini/$1'); | ||
309 | } | 315 | } |
310 | return `<a href="${href}">${match}</a>`; | 316 | return `<a href="${href}">${match}</a>`; |
311 | }); | 317 | }); |