forked from hound-search/hound
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,650 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ export function UrlParts(repo, path, line, rev) { | |
path = path || '', | ||
port = '', | ||
filename = path.substring(path.lastIndexOf('/') + 1), | ||
anchor = line ? ExpandVars(pattern.anchor, { line : line, filename : filename }) : ''; | ||
anchor = line ? ExpandVars(pattern.anchor, { line : line, filename : filename, repo : repo }) : ''; | ||
|
||
// Determine if the URL passed is a GitHub wiki | ||
var wikiUrl = /\.wiki$/.exec(url); | ||
|
@@ -28,25 +28,18 @@ export function UrlParts(repo, path, line, rev) { | |
anchor = '' // wikis do not support direct line linking | ||
} | ||
|
||
// Hacky solution to fix _some more_ of the 404's when using SSH style URLs. | ||
// This works for both github style URLs ([email protected]:username/Foo.git) and | ||
// bitbucket style URLs (ssh://[email protected]/username/Foo). | ||
// Check for ssh:// and hg:// protocol URLs | ||
// match the protocol, optionally a basic auth indicator, a | ||
// hostname, optionally a port, and then a path | ||
var ssh_protocol = /^(git|hg|ssh):\/\/([^@\/]+@)?([^:\/]+)(:[0-9]+)?\/(.*)/.exec(url); | ||
|
||
// Regex explained: Match either `git` or `hg` followed by an `@`. | ||
// Next, slurp up the hostname by reading until either a `:` or `/` is found. | ||
// If a port is specified, slurp that up too. Finally, grab the project and | ||
// repo names. | ||
var sshParts = /(git|hg)@(.*?)(:[0-9]+)?(:|\/)(.*)(\/)(.*)/.exec(url); | ||
if (sshParts) { | ||
hostname = '//' + sshParts[2] | ||
project = sshParts[5] | ||
repoName = sshParts[7] | ||
// Port is omitted in most cases. Bitbucket Server is special: | ||
// ssh://git@bitbucket.atlassian.com:7999/ATLASSIAN/jira.git | ||
if(sshParts[3]){ | ||
port = sshParts[3] | ||
} | ||
url = hostname + port + '/' + project + '/' + repoName; | ||
// Check for bare git+ssh URIs (e.g., user@hostname:path | ||
var bare_ssh = /^([^@]+)@([^:]+):(.*)/.exec(url); | ||
|
||
if (ssh_protocol) { | ||
url = '//' + ssh_protocol[3] + '/' + ssh_protocol[5]; | ||
} else if (bare_ssh) { | ||
url = '//' + bare_ssh[2] + '/' + bare_ssh[4]; | ||
} | ||
|
||
return { | ||
|
Oops, something went wrong.