mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-11 16:58:14 +00:00
Merge "Move possibly expensive title parser construction down"
This commit is contained in:
commit
5752b3feb1
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -12,9 +12,6 @@ const mw = mediaWiki;
|
|||
* @return {string|undefined}
|
||||
*/
|
||||
export function getTitle( href, config ) {
|
||||
const titleRegex = new RegExp( mw.RegExp.escape( config.get( 'wgArticlePath' ) )
|
||||
.replace( '\\$1', '([^?#]+)' ) );
|
||||
|
||||
// Skip every URI that mw.Uri cannot parse
|
||||
let linkHref;
|
||||
try {
|
||||
|
@ -33,7 +30,9 @@ export function getTitle( href, config ) {
|
|||
|
||||
// No query params (pretty URL)
|
||||
if ( !queryLength ) {
|
||||
const matches = titleRegex.exec( linkHref.path );
|
||||
const pattern = mw.RegExp.escape( config.get( 'wgArticlePath' ) ).replace( '\\$1', '([^?#]+)' ),
|
||||
matches = new RegExp( pattern ).exec( linkHref.path );
|
||||
|
||||
// We can't be sure decodeURIComponent() is able to parse every possible match
|
||||
try {
|
||||
title = matches && decodeURIComponent( matches[ 1 ] );
|
||||
|
|
Loading…
Reference in a new issue