@@ -3,6 +3,7 @@ import {svg} from '../svg.js';
33import { invertFileFolding } from './file-fold.js' ;
44import { createTippy } from '../modules/tippy.js' ;
55import { copyToClipboard } from './clipboard.js' ;
6+ import { toAbsoluteUrl } from '../utils.js' ;
67
78export const singleAnchorRegex = / ^ # ( L | n ) ( [ 1 - 9 ] [ 0 - 9 ] * ) $ / ;
89export const rangeAnchorRegex = / ^ # ( L [ 1 - 9 ] [ 0 - 9 ] * ) - ( L [ 1 - 9 ] [ 0 - 9 ] * ) $ / ;
@@ -19,17 +20,18 @@ function selectRange($list, $select, $from) {
1920 $list . removeClass ( 'active' ) ;
2021
2122 // add hashchange to permalink
22- const $issue = $ ( 'a.ref-in-new-issue' ) ;
23+ const $refInNewIssue = $ ( 'a.ref-in-new-issue' ) ;
2324 const $copyPermalink = $ ( 'a.copy-line-permalink' ) ;
2425 const $viewGitBlame = $ ( 'a.view_git_blame' ) ;
2526
2627 const updateIssueHref = function ( anchor ) {
27- if ( $issue . length === 0 ) {
28+ if ( $refInNewIssue . length === 0 ) {
2829 return ;
2930 }
30- let href = $issue . attr ( 'href' ) ;
31- href = `${ href . replace ( / % 2 3 L \d + $ | % 2 3 L \d + - L \d + $ / , '' ) } %23${ anchor } ` ;
32- $issue . attr ( 'href' , href ) ;
31+ const urlIssueNew = $refInNewIssue . attr ( 'data-url-issue-new' ) ;
32+ const urlParamBodyLink = $refInNewIssue . attr ( 'data-url-param-body-link' ) ;
33+ const issueContent = `${ toAbsoluteUrl ( urlParamBodyLink ) } #${ anchor } ` ; // the default content for issue body
34+ $refInNewIssue . attr ( 'href' , `${ urlIssueNew } ?body=${ encodeURIComponent ( issueContent ) } ` ) ;
3335 } ;
3436
3537 const updateViewGitBlameFragment = function ( anchor ) {
@@ -188,7 +190,7 @@ export function initRepoCodeView() {
188190 currentTarget . closest ( 'tr' ) . outerHTML = blob ;
189191 } ) ;
190192 $ ( document ) . on ( 'click' , '.copy-line-permalink' , async ( e ) => {
191- const success = await copyToClipboard ( e . currentTarget . getAttribute ( 'data-url' ) ) ;
193+ const success = await copyToClipboard ( toAbsoluteUrl ( e . currentTarget . getAttribute ( 'data-url' ) ) ) ;
192194 if ( ! success ) return ;
193195 document . querySelector ( '.code-line-button' ) ?. _tippy ?. hide ( ) ;
194196 } ) ;
0 commit comments