From: Stephane Bisson Date: Wed, 13 Dec 2017 18:29:43 +0000 (-0500) Subject: RCLFilters: support target page with a subpage X-Git-Tag: 1.31.0-rc.0~1212^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=bdb1d9894743e779662688295d59747390afff4f;p=lhc%2Fweb%2Fwiklou.git RCLFilters: support target page with a subpage Correctly extract the target page when it has a subpage. Examples (taken from unit tests): http://host/wiki/Special:RecentChangesLinked/Moai/Sub1 http://host/wiki/Special:RecentChangesLinked/Category:Foo/Bar http://host/w/index.php?title=Special:RecentChangesLinked/Moai/Sub1 Bug: T182734 Change-Id: Id6909728f461a3cd687185abd304f2fac5dc6000 --- diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js index 3e1191f392..05aa2fcf1c 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js @@ -100,7 +100,8 @@ */ mw.rcfilters.UriProcessor.prototype._normalizeTargetInUri = function ( uri ) { var parts, - re = /^((?:\/.+\/)?.+:.+)\/(.+)$/; // matches [namespace:]Title/Subpage + // matches [/wiki/]SpecialNS:RCL/[Namespace:]Title/Subpage/Subsubpage/etc + re = /^((?:\/.+?\/)?.*?:.*?)\/(.*)$/; // target in title param if ( uri.query.title ) { diff --git a/tests/qunit/suites/resources/mediawiki.rcfilters/UriProcessor.test.js b/tests/qunit/suites/resources/mediawiki.rcfilters/UriProcessor.test.js index 674bf07295..a234d1af82 100644 --- a/tests/qunit/suites/resources/mediawiki.rcfilters/UriProcessor.test.js +++ b/tests/qunit/suites/resources/mediawiki.rcfilters/UriProcessor.test.js @@ -285,16 +285,36 @@ output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai', message: 'Target as subpage in path' }, + { + input: 'http://host/wiki/Special:RecentChangesLinked/Moai/Sub1', + output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai/Sub1', + message: 'Target as subpage also has a subpage' + }, { input: 'http://host/wiki/Special:RecentChangesLinked/Category:Foo', output: 'http://host/wiki/Special:RecentChangesLinked?target=Category:Foo', message: 'Target as subpage in path (with namespace)' }, + { + input: 'http://host/wiki/Special:RecentChangesLinked/Category:Foo/Bar', + output: 'http://host/wiki/Special:RecentChangesLinked?target=Category:Foo/Bar', + message: 'Target as subpage in path also has a subpage (with namespace)' + }, { input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Moai', output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Moai', message: 'Target as subpage in title param' }, + { + input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Moai/Sub1', + output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Moai/Sub1', + message: 'Target as subpage in title param also has a subpage' + }, + { + input: 'http://host/w/index.php?title=Special:RecentChangesLinked/Category:Foo/Bar', + output: 'http://host/w/index.php?title=Special:RecentChangesLinked&target=Category:Foo/Bar', + message: 'Target as subpage in title param also has a subpage (with namespace)' + }, { input: 'http://host/wiki/Special:Watchlist', output: 'http://host/wiki/Special:Watchlist',