mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
chore: always adding sas extension
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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('')
|
||||
@@ -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('')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user