mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 10:01:39 -05:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
d286e36c55
3 changed files with 51 additions and 13 deletions
|
@ -101,10 +101,16 @@ function process() {
|
|||
console.log(clInput.value)
|
||||
sendExstr("hidecmdline")
|
||||
sendExstr(clInput.value)
|
||||
if (! browser.extension.inIncognitoContext) {
|
||||
|
||||
// Save non-secret commandlines to the history.
|
||||
const [func,...args] = clInput.value.trim().split(/\s+/)
|
||||
if (! browser.extension.inIncognitoContext &&
|
||||
! (func === 'winopen' && args[0] === '-private')
|
||||
) {
|
||||
state.cmdHistory = state.cmdHistory.concat([clInput.value])
|
||||
}
|
||||
console.log(state.cmdHistory)
|
||||
|
||||
completions.innerHTML = ""
|
||||
clInput.value = ""
|
||||
cmdline_history_position = 0
|
||||
|
|
|
@ -73,7 +73,7 @@ const SEARCH_URLS = new Map<string, string>([
|
|||
["duckduckgo","https://duckduckgo.com/?q="],
|
||||
["yahoo","https://search.yahoo.com/search?p="],
|
||||
["twitter","https://twitter.com/search?q="],
|
||||
["wikipedia","https://en.wikipedia.org/wiki/"],
|
||||
["wikipedia","https://en.wikipedia.org/wiki/Special:Search/"],
|
||||
["youtube","https://www.youtube.com/results?search_query="],
|
||||
["amazon","https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="],
|
||||
["amazonuk","https://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="],
|
||||
|
@ -85,21 +85,53 @@ function hasScheme(uri: string) {
|
|||
return uri.match(/^([\w-]+):/)
|
||||
}
|
||||
|
||||
/** We use this over encodeURIComponent so that '+'s in non queries are not encoded. */
|
||||
/** @hidden */
|
||||
function searchURL(provider: string, query: string) {
|
||||
if (SEARCH_URLS.has(provider)) {
|
||||
const url = new URL(SEARCH_URLS.get(provider) + query)
|
||||
// URL constructor doesn't convert +s because they're valid literals in
|
||||
// the standard it adheres to. But they are special characters in
|
||||
// x-www-form-urlencoded and e.g. google excepts query parameters in
|
||||
// that format.
|
||||
url.search = url.search.replace(/\+/g, '%2B')
|
||||
return url
|
||||
} else {
|
||||
throw new TypeError(`Unknown provider: '${provider}'`)
|
||||
}
|
||||
}
|
||||
|
||||
/** If maybeURI doesn't have a schema, affix http:// */
|
||||
/** @hidden */
|
||||
function forceURI(maybeURI: string) {
|
||||
if (hasScheme(maybeURI)) {
|
||||
return maybeURI
|
||||
function forceURI(maybeURI: string): string {
|
||||
try {
|
||||
return new URL(maybeURI).href
|
||||
} catch (e) {
|
||||
if (e.name !== 'TypeError') throw e
|
||||
}
|
||||
|
||||
let urlarr = maybeURI.split(" ")
|
||||
if (SEARCH_URLS.get(urlarr[0]) != null){
|
||||
return SEARCH_URLS.get(urlarr[0]) + urlarr.slice(1,urlarr.length).join(" ")
|
||||
} else if (urlarr[0].includes('.')) {
|
||||
return "http://" + maybeURI
|
||||
} else {
|
||||
return SEARCH_URLS.get("google") + maybeURI
|
||||
// Else if search keyword:
|
||||
try {
|
||||
const args = maybeURI.split(' ')
|
||||
return searchURL(args[0], args.slice(1).join(' ')).href
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
if (e.name !== 'TypeError') throw e
|
||||
}
|
||||
|
||||
// Else if it's a domain or something
|
||||
try {
|
||||
const url = new URL('http://' + maybeURI)
|
||||
// Ignore unlikely domains
|
||||
if (url.hostname.includes('.') || url.port || url.password) {
|
||||
return url.href
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.name !== 'TypeError') throw e
|
||||
}
|
||||
|
||||
// Else search google
|
||||
return searchURL('google', maybeURI).href
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Tridactyl",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"icons": {
|
||||
"64": "static/logo/Tridactyl_64px.png",
|
||||
"100": "static/logo/Tridactyl_100px.png",
|
||||
|
|
Loading…
Add table
Reference in a new issue