Add gh/gH to open home page
This commit is contained in:
parent
b735317c60
commit
1f89464e42
8 changed files with 65 additions and 13 deletions
|
@ -40,6 +40,7 @@ export default {
|
|||
|
||||
// Page
|
||||
PAGE_SOURCE: 'page.source',
|
||||
PAGE_HOME: 'page.home',
|
||||
|
||||
// Tabs
|
||||
TAB_CLOSE: 'tabs.close',
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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 };
|
||||
|
|
Reference in a new issue