RCLFilters: display target page as a title
authorStephane Bisson <sbisson@wikimedia.org>
Wed, 6 Dec 2017 21:57:40 +0000 (16:57 -0500)
committerStephane Bisson <sbisson@wikimedia.org>
Wed, 13 Dec 2017 20:37:57 +0000 (15:37 -0500)
* Url decode target param
* Pass through mw.Title to convert underscores to spaces

Bug: T182164
Change-Id: Iabb0d8ea2b9f93f943e8493ee0a29d3bee3b3682

resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.RclTargetPageWidget.js
tests/qunit/suites/resources/mediawiki.rcfilters/UriProcessor.test.js

index 05aa2fc..7bb0a22 100644 (file)
                }
 
                // target in path
-               parts = uri.path.match( re );
+               parts = mw.Uri.decode( uri.path ).match( re );
                if ( parts ) {
                        uri.path = parts[ 1 ];
                        uri.query.target = parts[ 2 ];
index 6673c08..d5c5e26 100644 (file)
@@ -71,6 +71,7 @@
         * Respond to the model being updated
         */
        mw.rcfilters.ui.RclTargetPageWidget.prototype.updateUiBasedOnModel = function () {
-               this.titleSearch.setValue( this.model.getValue() );
+               var title = mw.Title.newFromText( this.model.getValue() );
+               this.titleSearch.setValue( title ? title.toText() : this.model.getValue() );
        };
 }( mediaWiki ) );
index a234d1a..fbd159c 100644 (file)
                                        output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai',
                                        message: 'Target as subpage in path'
                                },
+                               {
+                                       input: 'http://host/wiki/Special:RecentChangesLinked/Château',
+                                       output: 'http://host/wiki/Special:RecentChangesLinked?target=Château',
+                                       message: 'Target as subpage in path with special characters'
+                               },
                                {
                                        input: 'http://host/wiki/Special:RecentChangesLinked/Moai/Sub1',
                                        output: 'http://host/wiki/Special:RecentChangesLinked?target=Moai/Sub1',