File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 5555 "chai-fs" : " ^2.0.0" ,
5656 "cross-env" : " ^5.1.3" ,
5757 "eslint" : " ^4.19.1" ,
58- "eslint-config-airbnb" : " ^ 17.0.0" ,
58+ "eslint-config-airbnb" : " ~ 17.0.0" ,
5959 "eslint-plugin-import" : " ^2.7.0" ,
6060 "eslint-plugin-jsx-a11y" : " ^6.0.2" ,
6161 "eslint-plugin-react" : " ^7.4.0" ,
Original file line number Diff line number Diff line change 1- import { normalizeFilesParam , buildFileParam , detectFormat } from './utils' ;
1+ import {
2+ normalizeFilesParam ,
3+ buildFileParam ,
4+ detectFormat ,
5+ detectConverter ,
6+ } from './utils' ;
27import Result from './result' ;
38
49const Task = class {
@@ -22,8 +27,9 @@ const Task = class {
2227 }
2328
2429 const fromFormat = this . fromFormat || detectFormat ( params , this . toFormat ) ;
25- const converter = params . converter ? `/converter/${ params . converter } ` : '' ;
26- const path = `convert/${ fromFormat } /to/${ this . toFormat } ${ converter } ` ;
30+ const converter = detectConverter ( params ) ;
31+ const converterPath = converter ? `/converter/${ converter } ` : '' ;
32+ const path = `convert/${ fromFormat } /to/${ this . toFormat } ${ converterPath } ` ;
2733 const response = await this . api . client . post ( path , params , timeout ) ;
2834
2935 return new Result ( this . api , response ) ;
Original file line number Diff line number Diff line change @@ -101,3 +101,11 @@ export const encodeFileName = (fileName) => {
101101 const str = encodeURIComponent ( fileName ) ;
102102 return str . replace ( / [ ! ' ( ) * ] / g, c => `%${ c . charCodeAt ( 0 ) . toString ( 16 ) } ` ) ;
103103} ;
104+
105+ export const detectConverter = ( params ) => {
106+ const converterKey = Object . keys ( params ) . find ( key => key . toLowerCase ( ) === 'converter' ) ;
107+
108+ if ( ! converterKey ) return undefined ;
109+
110+ return params [ converterKey ] ;
111+ } ;
You can’t perform that action at this time.
0 commit comments