From d736f4266ce5365b4a3995890313675ea196b0b1 Mon Sep 17 00:00:00 2001 From: Rohit Bhati Date: Thu, 3 Oct 2024 17:29:58 +0530 Subject: [PATCH] Fixed an issue where default EOL in the query tool should be based on the OS. #7393 --- web/pgadmin/static/js/utils.js | 13 +++++++++++++ .../static/js/components/QueryToolConstants.js | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/static/js/utils.js b/web/pgadmin/static/js/utils.js index edd3fdbc41f..ca191497255 100644 --- a/web/pgadmin/static/js/utils.js +++ b/web/pgadmin/static/js/utils.js @@ -736,3 +736,16 @@ export const memoizeTimeout = (fn, time) => new Proxy(fn, { return result; } }); + +export function getPlatform() { + const platform = navigator.userAgent; + if (platform.includes('Win')) { + return 'Windows'; + } else if (platform.includes('Mac')) { + return 'Mac'; + } else if (platform.includes('Linux')) { + return 'Linux'; + } else { + return 'Unknown'; + } +} \ No newline at end of file diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js index e33514e0787..2dd65e24bc2 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js @@ -7,6 +7,7 @@ // ////////////////////////////////////////////////////////////// import gettext from 'sources/gettext'; +import { getPlatform } from '../../../../../static/js/utils'; export const QUERY_TOOL_EVENTS = { TRIGGER_STOP_EXECUTION: 'TRIGGER_STOP_EXECUTION', @@ -113,4 +114,4 @@ export const PANELS = { export const MAX_QUERY_LENGTH = 1000000; -export const OS_EOL = navigator.platform === 'win32' ? 'crlf' : 'lf'; +export const OS_EOL = getPlatform() === 'Windows' ? 'crlf' : 'lf';