From 9bed6157351eea6fdbccff69aba5cc967a0b2a56 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Sat, 16 Nov 2019 00:55:25 +0100 Subject: Initial Gemini support --- js/main.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/main.ts b/js/main.ts index 7e0c8a1..2d11ea4 100644 --- a/js/main.ts +++ b/js/main.ts @@ -76,11 +76,15 @@ const settings = new KeyValueStore({ locationPrefixEls[i].addEventListener('click', e => { e.preventDefault(); - let resp = prompt('Please enter new location: ', ''); + let resp = prompt('Please enter new location (gopher://... or gemini://...):', ''); if ((resp !== null) && (resp.trim() !== "")) { resp = resp.trim(); if (resp.indexOf('gopher://') === 0) { - resp = resp.substring(9); + resp = 'gopher/' + resp.substring(9); + } else if (resp.indexOf('gemini://') === 0) { + resp = 'gemini/' + resp.substring(9); + } else { + resp = 'gopher/' + resp; } window.location.href = window.location.origin + '/' + resp; @@ -305,7 +309,9 @@ function generateMarkupForPlainLinks() { contentEl.innerHTML = contentEl.innerHTML.replace(urlRegex, match => { let href: string = match; if (href.indexOf('gopher://') === 0) { - href = href.replace(/^gopher:\/\/(.*)$/, location.origin + '/$1'); + href = href.replace(/^gopher:\/\/(.*)$/, location.origin + '/gopher/$1'); + } else if (href.indexOf('gemini://') === 0) { + href = href.replace(/^gemini:\/\/(.*)$/, location.origin + '/gemini/$1'); } return `${match}`; }); -- cgit v1.2.3-70-g09d2