Skip to content

Commit 69adb08

Browse files
committed
support url with prefix
1 parent ac1e81d commit 69adb08

File tree

1 file changed

+8
-7
lines changed
  • src/main/resources/embedding/assets

1 file changed

+8
-7
lines changed

src/main/resources/embedding/assets/entry.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $(function(){
4545
};
4646

4747
function convertLinks(){
48-
var matchPattern = new RegExp('https?://' + location.host + '/(\\w+)/(\\w+)/blob/(\\w+)/([\\w\\.]+)#L([0-9]+)(-L[0-9]+)?$');
48+
var matchPattern = new RegExp('https?://' + location.host + '(/\\w+)?/(\\w+)/(\\w+)/blob/(\\w+)/([\\w\\.]+)#L([0-9]+)(-L[0-9]+)?$');
4949
var elements = $('.markdown-body p a');
5050
var element;
5151
var url;
@@ -55,13 +55,14 @@ $(function(){
5555
url = element.innerText;
5656
mat = url.match(matchPattern);
5757
if(mat !== null){
58-
let owner = mat[1];
59-
let repo = mat[2];
60-
let commit = mat[3];
61-
let filename = mat[4];
62-
let startLine = Number(mat[5]);
58+
let urlPrefix = mat[1];
59+
let owner = mat[2];
60+
let repo = mat[3];
61+
let commit = mat[4];
62+
let filename = mat[5];
63+
let startLine = Number(mat[6]);
6364
let endLine = startLine;
64-
if(typeof mat[6] !== "undefined"){
65+
if(typeof mat[7] !== "undefined"){
6566
endLine = Number(mat[6].replace("-L", ""));
6667
};
6768
let commitUrl = getCommitUrl(mat)

0 commit comments

Comments
 (0)