Skip to content

Commit d630a2f

Browse files
author
Laurynas Butkus
committed
Make converter param name case insensitive
1 parent 27a0e92 commit d630a2f

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
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",

src/task.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { normalizeFilesParam, buildFileParam, detectFormat } from './utils';
1+
import {
2+
normalizeFilesParam,
3+
buildFileParam,
4+
detectFormat,
5+
detectConverter,
6+
} from './utils';
27
import Result from './result';
38

49
const 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);

src/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
};

0 commit comments

Comments
 (0)