diff --git a/src/routes/index.ts b/src/routes/index.ts index 1e9c681..1854f7d 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -7,7 +7,6 @@ import { import { ExecutionResult, isRequestQuery, isFileTree } from '../types' import path from 'path' import { - addSasExtensionIfNotFound, getTmpFilesFolderPath, getTmpFolderPath, makeFilesNamesMap @@ -63,7 +62,7 @@ router.get('/SASjsExecutor/do', async (req, res) => { .replace(new RegExp('/', 'g'), path.sep) // If no extension provided, add .sas extension - sasCodePath += addSasExtensionIfNotFound(sasCodePath) + sasCodePath += '.sas' await new ExecutionController() .execute(sasCodePath, undefined, undefined, { ...req.query }) @@ -96,7 +95,7 @@ router.post( .replace(new RegExp('/', 'g'), path.sep) // If no extension provided, add .sas extension - sasCodePath += addSasExtensionIfNotFound(sasCodePath) + sasCodePath += '.sas' let filesNamesMap = null diff --git a/src/utils/file.ts b/src/utils/file.ts index ead26e0..f819129 100644 --- a/src/utils/file.ts +++ b/src/utils/file.ts @@ -23,15 +23,4 @@ export const generateUniqueFileName = (fileName: string, extension = '') => '-', new Date().getTime(), extension - ].join('') - -export const addSasExtensionIfNotFound = (value: string) => { - const extension = 'sas' - const valueSplit = value.split('.') - - if (valueSplit.length < 2) return `.${extension}` - - const hasExt = valueSplit[valueSplit.length - 1].length === 3 - - return !hasExt ? `.${extension}` : '' -} + ].join('') \ No newline at end of file diff --git a/src/utils/spec/file.spec.ts b/src/utils/spec/file.spec.ts deleted file mode 100644 index 07616ac..0000000 --- a/src/utils/spec/file.spec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { addSasExtensionIfNotFound } from '..' - -describe('file utils', () => { - it('should add extension if missing', async () => { - expect(addSasExtensionIfNotFound('test')).toEqual('.sas') - expect(addSasExtensionIfNotFound('test.test')).toEqual('.sas') - expect(addSasExtensionIfNotFound('test.sas')).toEqual('') - expect(addSasExtensionIfNotFound('test.test.test')).toEqual('.sas') - expect(addSasExtensionIfNotFound('test.test.test.sas')).toEqual('') - }) -})