Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
navbar: when guessing scheme, tolerate slashes at the beginning and e…
Browse files Browse the repository at this point in the history
…nd of multihashes (close #212)
  • Loading branch information
pfrazee committed Dec 10, 2016
1 parent b4a0742 commit d66d307
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/shell-window/ui/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ function handleAutocompleteSearch (results) {
results.forEach(r => decorateResultMatches(searchTerms, r))

// does the value look like a url?
var multihashV = v.replace(/(^\/|\/$)/g,'') // strip leading and trailing slash
var isProbablyUrl = (!v.includes(' ') && (
/\.[A-z]/.test(v) ||
isDatHashRegex.test(v) ||
isIPFS.multihash(v) ||
isIPFS.multihash(multihashV) ||
isIPFS.ipfsPath(v) ||
isIPFS.ipnsPath(v) ||
v.startsWith('localhost') ||
Expand All @@ -296,8 +297,8 @@ function handleAutocompleteSearch (results) {
vWithProtocol = 'dat://'+v
} else if (v.startsWith('localhost')) {
vWithProtocol = 'http://'+v
} else if (isIPFS.multihash(v)) {
vWithProtocol = 'fs:/ipfs/' + v
} else if (isIPFS.multihash(multihashV)) {
vWithProtocol = 'fs:/ipfs/' + multihashV
} else if (isIPFS.ipfsPath(v) || isIPFS.ipnsPath(v)) {
vWithProtocol = 'fs:' + v
} else {
Expand Down

0 comments on commit d66d307

Please sign in to comment.