@@ -22,9 +22,9 @@ $(function(){
2222 return url . replace ( "/blob/" , "/raw/" ) ;
2323 } ;
2424
25- function getCommitUrl ( url , filename ) {
25+ function getCommitUrl ( url , filepath ) {
2626 url = url . replace ( "/blob/" , "/commit/" )
27- reg = new RegExp ( '/' + filename + '#L\\d+(-L\\d+)?$' )
27+ reg = new RegExp ( '/' + filepath + '#L\\d+(-L\\d+)?$' )
2828 return url . replace ( reg , "" )
2929 } ;
3030
@@ -43,7 +43,7 @@ $(function(){
4343 } ;
4444
4545 function convertLinks ( ) {
46- var matchPattern = new RegExp ( 'https?://' + location . host + '(/[\\w-\\.]+)?/([\\w-\\.]+)/([\\w-\\.]+)/blob/([\\w-\\.]+)/([\\w-\\.]+)#L([0-9]+)(-L [0-9]+)?$' ) ;
46+ var matchPattern = new RegExp ( 'https?://' + location . host + '(/[\\w-\\.]+)?/([\\w-\\.]+)/([\\w-\\.]+)/blob/([\\w-\\.]+)/([\\w-\\./ ]+)#L([0-9]+)-?L?( [0-9]+)?$' ) ;
4747 var elements = $ ( '.markdown-body p a' ) ;
4848 var element ;
4949 var url ;
@@ -57,18 +57,18 @@ $(function(){
5757 let owner = mat [ 2 ] ;
5858 let repo = mat [ 3 ] ;
5959 let commit = mat [ 4 ] ;
60- let filename = mat [ 5 ] ;
60+ let filepath = mat [ 5 ] ;
6161 let startLine = Number ( mat [ 6 ] ) ;
6262 let endLine = startLine ;
6363 if ( typeof mat [ 7 ] !== "undefined" ) {
64- endLine = Number ( mat [ 7 ] . replace ( "-L" , "" ) ) ;
64+ endLine = Number ( mat [ 7 ] ) ;
6565 } ;
66- let commitUrl = getCommitUrl ( url , filename )
66+ let commitUrl = getCommitUrl ( url , filepath )
6767 try {
6868 let content = getContent ( url ) ;
6969 let linesAll = content . split ( "\n" ) ;
7070 let lines = linesAll . slice ( startLine - 1 , endLine ) . join ( "\n" ) ;
71- let snippetElement = generateSnippetElement ( repo , filename , commit , startLine , endLine , lines , url , commitUrl ) ;
71+ let snippetElement = generateSnippetElement ( repo , filepath , commit , startLine , endLine , lines , url , commitUrl ) ;
7272 element . insertAdjacentHTML ( 'afterend' , snippetElement ) ;
7373 element . remove ( ) ;
7474 } catch ( e ) { }
0 commit comments