mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-12 09:18:59 +00:00
Merge "core: getTitle: Return undefined for non URI links"
This commit is contained in:
commit
8e694d13b7
|
@ -155,8 +155,14 @@
|
|||
* @return {string|undefined}
|
||||
*/
|
||||
mw.popups.getTitle = function ( href ) {
|
||||
var title, titleRegex, matches,
|
||||
var title, titleRegex, matches, linkHref;
|
||||
|
||||
// Skip every URI that mw.Uri cannot parse
|
||||
try {
|
||||
linkHref = new mw.Uri( href );
|
||||
} catch ( e ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// External links
|
||||
if ( linkHref.host !== location.hostname ) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
QUnit.test( 'getTitle', function ( assert ) {
|
||||
var cases, i, expected, actual;
|
||||
|
||||
QUnit.expect( 10 );
|
||||
QUnit.expect( 11 );
|
||||
cases = [
|
||||
[ '/wiki/Foo', 'Foo' ],
|
||||
[ '/wiki/Foo#Bar', 'Foo' ],
|
||||
|
@ -20,7 +20,10 @@
|
|||
[ '/w/Foo?title=Foo&action=edit', undefined ],
|
||||
[ '/w/index.php?title=%E6%B8%AC%E8%A9%A6', '測試' ],
|
||||
[ '/w/index.php?oldid=1', undefined ],
|
||||
[ '/Foo', undefined ]
|
||||
[ '/Foo', undefined ],
|
||||
/*jshint -W107 */
|
||||
[ 'javascript:void(0);', undefined ]
|
||||
/*jshint +W107 */
|
||||
];
|
||||
|
||||
for ( i = 0; i < cases.length; i++ ) {
|
||||
|
|
Loading…
Reference in a new issue