Fix broken reference popup when name contains # character

The fragment in a URL like http://example.com/foo#bar#baz doesn't end
when there is another # somewhere. That # is part of the fragment.

I'm not sure since when this issue exists. It's already in the first
version of this codebase from 2017, see Iff1f7e6.

Bug: T332007
Change-Id: I3b0726380d2f385475f5ba53aeab16932d7ccaa7
This commit is contained in:
thiemowmde 2023-12-12 15:03:42 +01:00
parent 14cd6c3a4d
commit e0d893c0f5

View file

@ -16,17 +16,16 @@ module.exports = function () {
* @param {jQuery.Event} ev Click event of the reference element * @param {jQuery.Event} ev Click event of the reference element
*/ */
function showReference( ev ) { function showReference( ev ) {
var urlComponents, var $dest = $( ev.currentTarget ),
$dest = $( ev.currentTarget ),
href = $dest.attr( 'href' ); href = $dest.attr( 'href' );
ev.preventDefault(); ev.preventDefault();
// If necessary strip the URL portion of the href so we are left with the // If necessary strip the URL portion of the href so we are left with the
// fragment // fragment
urlComponents = href.split( '#' ); var i = href.indexOf( '#' );
if ( urlComponents.length > 1 ) { if ( i > 0 ) {
href = '#' + urlComponents[ 1 ]; href = href.slice( i );
} }
references.showReference( href, currentPage, $dest.text(), references.showReference( href, currentPage, $dest.text(),