Skip to content

Commit

Permalink
Merge pull request #86 from ConvertAPI/feature/remove-alternative-con…
Browse files Browse the repository at this point in the history
…verter

Remove alternative converter support
  • Loading branch information
laurynas-convertapi authored Sep 14, 2024
2 parents 3fc2cbe + fe757d8 commit ab9efb6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 40 deletions.
21 changes: 0 additions & 21 deletions examples/alternative_converter.js

This file was deleted.

5 changes: 1 addition & 4 deletions src/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
normalizeFilesParam,
buildFileParam,
detectFormat,
detectConverter,
} from './utils';
import Result from './result';

Expand All @@ -27,9 +26,7 @@ const Task = class {
}

const fromFormat = this.fromFormat || detectFormat(params, this.toFormat);
const converter = detectConverter(params);
const converterPath = converter ? `/converter/${converter}` : '';
const path = `convert/${fromFormat}/to/${this.toFormat}${converterPath}`;
const path = `convert/${fromFormat}/to/${this.toFormat}`;
const response = await this.api.client.post(path, params, timeout);

return new Result(this.api, response);
Expand Down
8 changes: 0 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,3 @@ export const encodeFileName = (fileName) => {
const str = encodeURIComponent(fileName);
return str.replace(/[!'()*]/g, c => `%${c.charCodeAt(0).toString(16)}`);
};

export const detectConverter = (params) => {
const converterKey = Object.keys(params).find(key => key.toLowerCase() === 'converter');

if (!converterKey) return undefined;

return params[converterKey];
};
7 changes: 0 additions & 7 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ describe('ConvertAPI', () => {
expect(result.file.url).to.be.a('string');
});

it ('should convert file using alternative converter', async () => {
const params = { File: 'https://cdn.convertapi.com/cara/testfiles/document.docx?test=1', converter: 'openoffice' };
const result = await api.convert('pdf', params);

expect(result.file.url).to.be.a('string');
});

it('should convert url to pdf', async () => {
const params = { Url: 'http://convertapi.com' };
const result = await api.convert('pdf', params, 'web');
Expand Down

0 comments on commit ab9efb6

Please sign in to comment.