@@ -36,24 +36,30 @@ var gitHosts = module.exports = {
3636 'sshtemplate' : 'git@{domain}:/{project}.git{#committish}' ,
3737 'sshurltemplate' : 'git+ssh://git@{domain}/{project}.git{#committish}' ,
3838 'browsetemplate' : 'https://{domain}/{project}{/committish}' ,
39+ 'browsefiletemplate' : 'https://{domain}/{project}{/committish}{#path}' ,
3940 'docstemplate' : 'https://{domain}/{project}{/committish}' ,
4041 'httpstemplate' : 'git+https://{domain}/{project}.git{#committish}' ,
4142 'shortcuttemplate' : '{type}:{project}{#committish}' ,
4243 'pathtemplate' : '{project}{#committish}' ,
43- 'tarballtemplate' : 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
44+ 'tarballtemplate' : 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz' ,
45+ 'hashformat' : function ( fragment ) {
46+ return 'file-' + formatHashFragment ( fragment )
47+ }
4448 }
4549}
4650
4751var gitHostDefaults = {
4852 'sshtemplate' : 'git@{domain}:{user}/{project}.git{#committish}' ,
4953 'sshurltemplate' : 'git+ssh://git@{domain}/{user}/{project}.git{#committish}' ,
5054 'browsetemplate' : 'https://{domain}/{user}/{project}{/tree/committish}' ,
55+ 'browsefiletemplate' : 'https://{domain}/{user}/{project}/{treepath}/{committish}/{path}{#fragment}' ,
5156 'docstemplate' : 'https://{domain}/{user}/{project}{/tree/committish}#readme' ,
5257 'httpstemplate' : 'git+https://{auth@}{domain}/{user}/{project}.git{#committish}' ,
5358 'filetemplate' : 'https://{domain}/{user}/{project}/raw/{committish}/{path}' ,
5459 'shortcuttemplate' : '{type}:{user}/{project}{#committish}' ,
5560 'pathtemplate' : '{user}/{project}{#committish}' ,
56- 'pathmatch' : / ^ [ / ] ( [ ^ / ] + ) [ / ] ( [ ^ / ] + ?) (?: [ . ] g i t | [ / ] ) ? $ /
61+ 'pathmatch' : / ^ [ / ] ( [ ^ / ] + ) [ / ] ( [ ^ / ] + ?) (?: [ . ] g i t | [ / ] ) ? $ / ,
62+ 'hashformat' : formatHashFragment
5763}
5864
5965Object . keys ( gitHosts ) . forEach ( function ( name ) {
@@ -66,3 +72,7 @@ Object.keys(gitHosts).forEach(function (name) {
6672 return protocol . replace ( / ( [ \\ + * { } ( ) [ \] $ ^ | ] ) / g, '\\$1' )
6773 } ) . join ( '|' ) + '):$' )
6874} )
75+
76+ function formatHashFragment ( fragment ) {
77+ return fragment . toLowerCase ( ) . replace ( / ^ \W + | \/ | \W + $ / g, '' ) . replace ( / \W + / g, '-' )
78+ }
0 commit comments