diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-29 00:04:24 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-29 00:04:24 +0900 |
commit | af90ef59566210fa8715816d639ae1025f2aa2fb (patch) | |
tree | 0c66e88229b11c9b154772a6a93dbb6def0d6dcf /src/content/urls.js | |
parent | ed2bd7d75ee1e7aa1db7d03c3f908c740ded1983 (diff) | |
parent | 09c5247dbadb468a764eef308634503484d398c5 (diff) |
Merge pull request #441 from ueokande/search-on-paste
Search on paste
Diffstat (limited to 'src/content/urls.js')
-rw-r--r-- | src/content/urls.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/content/urls.js b/src/content/urls.js index 9b7b284..1c5b7e5 100644 --- a/src/content/urls.js +++ b/src/content/urls.js @@ -1,4 +1,5 @@ import messages from 'shared/messages'; +import * as urls from '../shared/urls'; const yank = (win) => { let input = win.document.createElement('input'); @@ -14,7 +15,7 @@ const yank = (win) => { input.remove(); }; -const paste = (win, newTab) => { +const paste = (win, newTab, searchSettings) => { let textarea = win.document.createElement('textarea'); win.document.body.append(textarea); @@ -24,13 +25,13 @@ const paste = (win, newTab) => { textarea.focus(); if (win.document.execCommand('paste')) { - if (/^(https?|ftp):\/\//.test(textarea.textContent)) { - browser.runtime.sendMessage({ - type: messages.OPEN_URL, - url: textarea.textContent, - newTab: newTab ? newTab : false, - }); - } + let value = textarea.textContent; + let url = urls.normalizeUrl(value, searchSettings); + browser.runtime.sendMessage({ + type: messages.OPEN_URL, + url, + newTab, + }); } textarea.remove(); |