Add gh/gH to open home page

This commit is contained in:
Shin'ya Ueoka 2018-12-09 10:19:08 +09:00
parent b735317c60
commit 1f89464e42
8 changed files with 65 additions and 13 deletions

View file

@ -40,6 +40,7 @@ export default {
// Page
PAGE_SOURCE: 'page.source',
PAGE_HOME: 'page.home',
// Tabs
TAB_CLOSE: 'tabs.close',

View file

@ -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 },

View file

@ -5,7 +5,7 @@ const trimStart = (str) => {
const SUPPORTED_PROTOCOLS = ['http:', 'https:', 'ftp:', 'mailto:'];
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 };