Parcourir la source

Merge pull request #10 from ckeditor/t/9

Fix: Prevented UploadGateway from being created when cloudServices#tokenUrl is not provided. Closes #9.
Piotr Jasiun il y a 8 ans
Parent
commit
edffa0a7fb

+ 4 - 0
packages/ckeditor5-easy-image/src/cloudservicesuploadadapter.js

@@ -41,6 +41,10 @@ export default class CloudServicesUploadAdapter extends Plugin {
 		const token = cloudServices.token;
 		const uploadUrl = cloudServices.uploadUrl || 'https://files.cke-cs.com/upload/';
 
+		if ( !token ) {
+			return;
+		}
+
 		this._uploadGateway = new CloudServicesUploadAdapter._UploadGateway( token, uploadUrl );
 
 		editor.plugins.get( FileRepository ).createAdapter = loader => {

+ 14 - 0
packages/ckeditor5-easy-image/tests/cloudservicesuploadadapter.js

@@ -60,6 +60,20 @@ describe( 'CloudServicesUploadAdapter', () => {
 				} );
 		} );
 
+		it( 'should not set loader if there is no token', () => {
+			UploadGatewayMock.lastToken = undefined;
+
+			return ClassicTestEditor
+				.create( div, {
+					plugins: [ CloudServicesUploadAdapter ]
+				} )
+				.then( editor => {
+					expect( UploadGatewayMock.lastToken ).to.be.undefined;
+
+					return editor.destroy();
+				} );
+		} );
+
 		it( 'should set the default uploadUrl', () => {
 			const expectedDefaultUrl = 'https://files.cke-cs.com/upload/';