Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistent search behavior - '%s' format vs append #475

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions content_scripts/complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,28 @@ var Complete = {
return '';

input[0] = this.getAlias(input[0]) || input[0];
if (!this.hasEngine(input[0])) {
var engine = null;
if (this.hasEngine(input[0])) {
engine = this.getEngine(input[0]);
input = input.slice(1);
if (input.length == 0)
return engine.baseUrl;
} else {
if (!isLink && (isURL || input.join(' ').validURL())) {
input = input.join(' ');
return (!/^[a-zA-Z\-]+:/.test(input) ? 'http://' : '') +
input;
}
var defaultEngine = this.getEngine(settings.defaultengine);
return (defaultEngine ? defaultEngine.requestUrl :
this.getEngine('google').requestUrl) +
encodeURIComponent(input.join(' '));
engine = this.getEngine(settings.defaultengine) || this.getEngine('google');
}

var engine = this.getEngine(input[0]);
if (input.length <= 1)
return engine.baseUrl;

var prefix = engine.requestUrl;
var suffix = engine.hasOwnProperty('formatRequest') ?
engine.formatRequest(input.slice(1).join(' ')) :
encodeURIComponent(input.slice(1).join(' '));
engine.formatRequest(input.join(' ')) :
encodeURIComponent(input.join(' '));

console.log('prefix: ', prefix)
console.log('suffix: ', suffix)

if (suffix.validURL())
return suffix.convertLink();
Expand Down