quick-tabs/popup.js
/**
 * open a new tab with `searchString`, if it looks like a valid URL open that
 * otherwise pass it as an encoded search string to a search engine.
 *
 * @param searchString
 */
open a new tab with `searchString`, if it looks like a valid URL open that
otherwise pass it as an encoded search string to a search engine.

@param searchString
open a new tab with ` searchString ` if it looks like a valid URL open that otherwise pass it as an encoded search string to a search engine . @param searchString
function openTabForSearch(searchString) {
  let url = searchStringAsUrl(searchString);
  if (/^(http|https|ftp):\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?,'/\\\+&amp;%$#=~])*$/.exec(url)) {
    log("no tab selected, search string looks like a url, opening in new tab", searchString, url);
    chrome.tabs.create({url: url});
  } else {
    log("no tab selected, passing search string to search engine", searchString, url);
    let searchUrl = bg.getSearchString().replace(/%s/g, encodeURI(searchString));
    chrome.tabs.create({url: searchUrl});
  }
}
function openTabForSearch ( searchString ) { let url = searchStringAsUrl ( searchString ) ; if ( / ^(http|https|ftp):\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?,'/\\\+&amp;%$#=~])*$ / . exec ( url ) ) { log ( "no tab selected, search string looks like a url, opening in new tab" , searchString , url ) ; chrome . tabs . create ( { url : url } ) ; } else { log ( "no tab selected, passing search string to search engine" , searchString , url ) ; let searchUrl = bg . getSearchString ( ) . replace ( / %s / g , encodeURI ( searchString ) ) ; chrome . tabs . create ( { url : searchUrl } ) ; } }
open a new tab with `searchString`, if it looks like a valid URL open that
 otherwise pass it as an encoded search string to a search engine.
open a new tab with ` searchString ` if it looks like a valid URL open that otherwise pass it as an encoded search string to a search engine .
//url = "http://www.google.com/search?q=" + encodeURI($("input[type=text]").val());