Merge "Use POST to submit wikitext to mw.api.parse"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 30 Apr 2019 12:38:45 +0000 (12:38 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 30 Apr 2019 12:38:45 +0000 (12:38 +0000)
resources/src/mediawiki.api/parse.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js

index 42b0771..447b936 100644 (file)
                        if ( mw.Title && content instanceof mw.Title ) {
                                // Parse existing page
                                config.page = content.getPrefixedDb();
+                               apiPromise = this.get( config );
                        } else {
                                // Parse wikitext from input
                                config.text = String( content );
+                               apiPromise = this.post( config );
                        }
 
-                       apiPromise = this.get( config );
-
                        return apiPromise
                                .then( function ( data ) {
                                        return data.parse.text;
index 0bcce12..29cffaf 100644 (file)
@@ -7,7 +7,7 @@
        } ) );
 
        QUnit.test( '.parse( string )', function ( assert ) {
-               this.server.respondWith( /action=parse.*&text='''Hello(\+|%20)world'''/, [ 200,
+               this.server.respondWith( 'POST', /api.php/, [ 200,
                        { 'Content-Type': 'application/json' },
                        '{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
                ] );
@@ -18,7 +18,7 @@
        } );
 
        QUnit.test( '.parse( Object.toString )', function ( assert ) {
-               this.server.respondWith( /action=parse.*&text='''Hello(\+|%20)world'''/, [ 200,
+               this.server.respondWith( 'POST', /api.php/, [ 200,
                        { 'Content-Type': 'application/json' },
                        '{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
                ] );
@@ -33,7 +33,7 @@
        } );
 
        QUnit.test( '.parse( mw.Title )', function ( assert ) {
-               this.server.respondWith( /action=parse.*&page=Earth/, [ 200,
+               this.server.respondWith( 'GET', /action=parse.*&page=Earth/, [ 200,
                        { 'Content-Type': 'application/json' },
                        '{ "parse": { "text": "<p><b>Earth</b> is a planet.</p>" } }'
                ] );