1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 11:24:35 +00:00

Merge pull request #289 from sasjs/issue-288

fix: made files extensions case insensitive
This commit is contained in:
Allan Bowe
2022-09-22 16:47:00 +01:00
committed by GitHub
2 changed files with 6 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import { getFilesFolder } from './file'
import { RunTimeType } from '.'
export const getRunTimeAndFilePath = async (programPath: string) => {
const ext = path.extname(programPath)
const ext = path.extname(programPath).toLowerCase()
// If programPath (_program) is provided with a ".sas", ".js", ".py" or ".r" extension
// we should use that extension to determine the appropriate runTime
if (ext && Object.values(RunTimeType).includes(ext.slice(1) as RunTimeType)) {

View File

@@ -236,7 +236,9 @@ const useEditor = ({
useEffect(() => {
if (selectedFilePath) {
setIsLoading(true)
setSelectedFileExtension(selectedFilePath.split('.').pop() ?? '')
setSelectedFileExtension(
selectedFilePath.split('.').pop()?.toLowerCase() ?? ''
)
axios
.get(`/SASjsApi/drive/file?_filePath=${selectedFilePath}`)
.then((res: any) => {
@@ -270,8 +272,8 @@ const useEditor = ({
}, [fileContent, selectedFilePath])
useEffect(() => {
if (runTimes.includes(selectedFileExtension))
setSelectedRunTime(selectedFileExtension)
const fileExtension = selectedFileExtension.toLowerCase()
if (runTimes.includes(fileExtension)) setSelectedRunTime(fileExtension)
}, [selectedFileExtension, runTimes])
return {