diff options
| author | Stephen Blott | 2016-04-17 08:46:57 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2016-04-17 08:53:00 +0100 | 
| commit | 9f91a3fc41a9ad97e1e92337819145e604ac4f34 (patch) | |
| tree | 0e0e802ee6226b9b2d14cdb243b12deb69602db6 | |
| parent | a57b7ea02d9c40580c3238f240bd9fae7d50d6f7 (diff) | |
| download | vimium-9f91a3fc41a9ad97e1e92337819145e604ac4f34.tar.bz2 | |
For javascript URLs, do not match javascript content.
We only match the text "javascript:...".
The affects only the bookmark completer.
| -rw-r--r-- | background_scripts/completion.coffee | 16 | 
1 files changed, 9 insertions, 7 deletions
| diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 9980fb10..db69f15c 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -66,15 +66,11 @@ class Suggestion             <span class="vimiumReset vomnibarTitle">#{@highlightQueryTerms Utils.escapeHtml @title}</span>           </div>           <div class="vimiumReset vomnibarBottomHalf"> -          <span class="vimiumReset vomnibarSource vomnibarNoInsertText">#{insertTextIndicator}</span><span class="vimiumReset vomnibarUrl">#{@highlightUrlTerms Utils.escapeHtml @simplifyJavascriptUrls @shortenUrl()}</span> +          <span class="vimiumReset vomnibarSource vomnibarNoInsertText">#{insertTextIndicator}</span><span class="vimiumReset vomnibarUrl">#{@highlightUrlTerms Utils.escapeHtml @shortenUrl()}</span>            #{relevancyHtml}          </div>          """ -  # Simplify "javascript:" URLs; show them as "javascript:..."; see #961. -  simplifyJavascriptUrls: (url) -> -    if Utils.hasJavascriptPrefix(url) then "javascript:..." else url -    # Use neat trick to snatch a domain (http://stackoverflow.com/a/8498668).    getUrlRoot: (url) ->      a = document.createElement 'a' @@ -150,6 +146,8 @@ class Suggestion    # Simplify a suggestion's URL (by removing those parts which aren't useful for display or comparison).    shortenUrl: () -> +    # If we already have display URL, then use it. +    @shortUrl ?= @displayUrl      return @shortUrl if @shortUrl?      # We get easier-to-read shortened URLs if we URI-decode them.      url = (Utils.decodeURIByParts(@url) || @url).toLowerCase() @@ -208,7 +206,10 @@ class BookmarkCompleter        if @currentSearch.queryTerms.length > 0          @bookmarks.filter (bookmark) =>            suggestionTitle = if usePathAndTitle then bookmark.pathAndTitle else bookmark.title -          RankingUtils.matches(@currentSearch.queryTerms, bookmark.url, suggestionTitle) +          bookmark.hasJavascriptPrefix ?= Utils.hasJavascriptPrefix bookmark.url +          bookmark.displayUrl ?= "javascript:..." if bookmark.hasJavascriptPrefix +          suggestionUrl = bookmark.displayUrl ? bookmark.url +          RankingUtils.matches(@currentSearch.queryTerms, suggestionUrl, suggestionTitle)        else          []      suggestions = results.map (bookmark) => @@ -216,6 +217,7 @@ class BookmarkCompleter          queryTerms: @currentSearch.queryTerms          type: "bookmark"          url: bookmark.url +        displayUrl: bookmark.displayUrl          title: if usePathAndTitle then bookmark.pathAndTitle else bookmark.title          relevancyFunction: @computeRelevancy      onComplete = @currentSearch.onComplete @@ -252,7 +254,7 @@ class BookmarkCompleter      bookmark.children.forEach((child) => @traverseBookmarksRecursive child, results, bookmark) if bookmark.children    computeRelevancy: (suggestion) -> -    RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) +    RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.displayUrl ? suggestion.url, suggestion.title)  class HistoryCompleter    filter: ({ queryTerms, seenTabToOpenCompletionList }, onComplete) -> | 
