@@ -22,9 +22,9 @@ $(function(){
22
22
return url . replace ( "/blob/" , "/raw/" ) ;
23
23
} ;
24
24
25
- function getCommitUrl ( url , filename ) {
25
+ function getCommitUrl ( url , filepath ) {
26
26
url = url . replace ( "/blob/" , "/commit/" )
27
- reg = new RegExp ( '/' + filename + '#L\\d+(-L\\d+)?$' )
27
+ reg = new RegExp ( '/' + filepath + '#L\\d+(-L\\d+)?$' )
28
28
return url . replace ( reg , "" )
29
29
} ;
30
30
@@ -43,7 +43,7 @@ $(function(){
43
43
} ;
44
44
45
45
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]+)?$' ) ;
47
47
var elements = $ ( '.markdown-body p a' ) ;
48
48
var element ;
49
49
var url ;
@@ -57,18 +57,18 @@ $(function(){
57
57
let owner = mat [ 2 ] ;
58
58
let repo = mat [ 3 ] ;
59
59
let commit = mat [ 4 ] ;
60
- let filename = mat [ 5 ] ;
60
+ let filepath = mat [ 5 ] ;
61
61
let startLine = Number ( mat [ 6 ] ) ;
62
62
let endLine = startLine ;
63
63
if ( typeof mat [ 7 ] !== "undefined" ) {
64
- endLine = Number ( mat [ 7 ] . replace ( "-L" , "" ) ) ;
64
+ endLine = Number ( mat [ 7 ] ) ;
65
65
} ;
66
- let commitUrl = getCommitUrl ( url , filename )
66
+ let commitUrl = getCommitUrl ( url , filepath )
67
67
try {
68
68
let content = getContent ( url ) ;
69
69
let linesAll = content . split ( "\n" ) ;
70
70
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 ) ;
72
72
element . insertAdjacentHTML ( 'afterend' , snippetElement ) ;
73
73
element . remove ( ) ;
74
74
} catch ( e ) { }
0 commit comments