From 249604384e42be4c12c88c70a7dff90fc1917a8f Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Thu, 22 Sep 2022 20:37:16 +0500 Subject: [PATCH] fix: made files extensions case insensitive --- api/src/utils/getRunTimeAndFilePath.ts | 2 +- web/src/containers/Studio/internal/hooks/useEditor.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/utils/getRunTimeAndFilePath.ts b/api/src/utils/getRunTimeAndFilePath.ts index 340892a..fcabbe6 100644 --- a/api/src/utils/getRunTimeAndFilePath.ts +++ b/api/src/utils/getRunTimeAndFilePath.ts @@ -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)) { diff --git a/web/src/containers/Studio/internal/hooks/useEditor.ts b/web/src/containers/Studio/internal/hooks/useEditor.ts index 4a12bdb..17bcb83 100644 --- a/web/src/containers/Studio/internal/hooks/useEditor.ts +++ b/web/src/containers/Studio/internal/hooks/useEditor.ts @@ -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 {