mirror of
https://github.com/sasjs/server.git
synced 2026-01-14 09:20:06 +00:00
chore: extension util fix
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
import { ExecutionResult, isRequestQuery, isFileTree } from '../types'
|
import { ExecutionResult, isRequestQuery, isFileTree } from '../types'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import {
|
import {
|
||||||
addExtensionIfNotFound,
|
addSasExtensionIfNotFound,
|
||||||
getTmpFilesFolderPath,
|
getTmpFilesFolderPath,
|
||||||
getTmpFolderPath,
|
getTmpFolderPath,
|
||||||
makeFilesNamesMap
|
makeFilesNamesMap
|
||||||
@@ -63,7 +63,7 @@ router.get('/SASjsExecutor/do', async (req, res) => {
|
|||||||
.replace(new RegExp('/', 'g'), path.sep)
|
.replace(new RegExp('/', 'g'), path.sep)
|
||||||
|
|
||||||
// If no extension provided, add .sas extension
|
// If no extension provided, add .sas extension
|
||||||
sasCodePath += addExtensionIfNotFound(sasCodePath, 'sas')
|
sasCodePath += addSasExtensionIfNotFound(sasCodePath)
|
||||||
|
|
||||||
await new ExecutionController()
|
await new ExecutionController()
|
||||||
.execute(sasCodePath, undefined, undefined, { ...req.query })
|
.execute(sasCodePath, undefined, undefined, { ...req.query })
|
||||||
@@ -96,7 +96,7 @@ router.post(
|
|||||||
.replace(new RegExp('/', 'g'), path.sep)
|
.replace(new RegExp('/', 'g'), path.sep)
|
||||||
|
|
||||||
// If no extension provided, add .sas extension
|
// If no extension provided, add .sas extension
|
||||||
sasCodePath += addExtensionIfNotFound(sasCodePath, 'sas')
|
sasCodePath += addSasExtensionIfNotFound(sasCodePath)
|
||||||
|
|
||||||
let filesNamesMap = null
|
let filesNamesMap = null
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ export const generateUniqueFileName = (fileName: string, extension = '') =>
|
|||||||
extension
|
extension
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
export const addExtensionIfNotFound = (value: string, extension: string) => {
|
export const addSasExtensionIfNotFound = (value: string) => {
|
||||||
|
const extension = 'sas'
|
||||||
const valueSplit = value.split('.')
|
const valueSplit = value.split('.')
|
||||||
|
|
||||||
if (valueSplit.length < 2) return `.${extension}`
|
if (valueSplit.length < 2) return `.${extension}`
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { addExtensionIfNotFound } from '..'
|
import { addSasExtensionIfNotFound } from '..'
|
||||||
|
|
||||||
describe('file utils', () => {
|
describe('file utils', () => {
|
||||||
it('should add extension if missing', async () => {
|
it('should add extension if missing', async () => {
|
||||||
expect(addExtensionIfNotFound('test', 'ext')).toEqual('.ext')
|
expect(addSasExtensionIfNotFound('test')).toEqual('.sas')
|
||||||
expect(addExtensionIfNotFound('test.test', 'ext')).toEqual('.ext')
|
expect(addSasExtensionIfNotFound('test.test')).toEqual('.sas')
|
||||||
expect(addExtensionIfNotFound('test.sas', 'ext')).toEqual('')
|
expect(addSasExtensionIfNotFound('test.sas')).toEqual('')
|
||||||
expect(addExtensionIfNotFound('test.test.test', 'ext')).toEqual('.ext')
|
expect(addSasExtensionIfNotFound('test.test.test')).toEqual('.sas')
|
||||||
expect(addExtensionIfNotFound('test.test.test.sas', 'ext')).toEqual('')
|
expect(addSasExtensionIfNotFound('test.test.test.sas')).toEqual('')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user