diff options
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/operations.js | 1 | ||||
| -rw-r--r-- | src/shared/settings/default.js | 2 | ||||
| -rw-r--r-- | src/shared/urls.js | 22 | 
3 files changed, 22 insertions, 3 deletions
| diff --git a/src/shared/operations.js b/src/shared/operations.js index 778b1cf..026f97c 100644 --- a/src/shared/operations.js +++ b/src/shared/operations.js @@ -40,6 +40,7 @@ export default {    // Page    PAGE_SOURCE: 'page.source', +  PAGE_HOME: 'page.home',    // Tabs    TAB_CLOSE: 'tabs.close', diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js index 4163064..5b0950e 100644 --- a/src/shared/settings/default.js +++ b/src/shared/settings/default.js @@ -52,6 +52,8 @@ export default {      "gU": { "type": "navigate.root" },      "gi": { "type": "focus.input" },      "gf": { "type": "page.source" }, +    "gh": { "type": "page.home" }, +    "gH": { "type": "page.home", "newTab": true },      "y": { "type": "urls.yank" },      "p": { "type": "urls.paste", "newTab": false },      "P": { "type": "urls.paste", "newTab": true }, diff --git a/src/shared/urls.js b/src/shared/urls.js index d6c31e6..f7e917d 100644 --- a/src/shared/urls.js +++ b/src/shared/urls.js @@ -3,9 +3,9 @@ const trimStart = (str) => {    return str.replace(/^\s+/, '');  }; -const SUPPORTED_PROTOCOLS = ['http:', 'https:', 'ftp:', 'mailto:']; +const SUPPORTED_PROTOCOLS = ['http:', 'https:', 'ftp:', 'mailto:', 'about:']; -const normalizeUrl = (keywords, searchSettings) => { +const searchUrl = (keywords, searchSettings) => {    try {      let u = new URL(keywords);      if (SUPPORTED_PROTOCOLS.includes(u.protocol.toLowerCase())) { @@ -28,4 +28,20 @@ const normalizeUrl = (keywords, searchSettings) => {    return template.replace('{}', encodeURIComponent(query));  }; -export { normalizeUrl }; +const normalizeUrl = (url) => { +  try { +    let u = new URL(url); +    if (SUPPORTED_PROTOCOLS.includes(u.protocol.toLowerCase())) { +      return u.href; +    } +  } catch (e) { +    // fallthrough +  } +  return 'http://' + url; +}; + +const homepageUrls = (value) => { +  return value.split('|').map(normalizeUrl); +}; + +export { searchUrl, normalizeUrl, homepageUrls }; | 
