diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2024-01-26 08:24:20 +0530 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2024-01-28 03:31:35 +0000 |
commit | 6c67387b2978f1a02244a1350725238da35b341b (patch) | |
tree | c357ab6826cce8272642c01b0d80120bd5baaa86 /src/helpers | |
parent | 6.7.1-nightly.11 [skip ci] (diff) | |
download | ferdium-app-6c67387b2978f1a02244a1350725238da35b341b.tar.gz ferdium-app-6c67387b2978f1a02244a1350725238da35b341b.tar.zst ferdium-app-6c67387b2978f1a02244a1350725238da35b341b.zip |
chore: minor refactoring to reduce lines and add tests
Diffstat (limited to 'src/helpers')
-rw-r--r-- | src/helpers/certs-helpers.ts | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/helpers/certs-helpers.ts b/src/helpers/certs-helpers.ts index a81e7e365..a6c83f5c4 100644 --- a/src/helpers/certs-helpers.ts +++ b/src/helpers/certs-helpers.ts | |||
@@ -1,12 +1,9 @@ | |||
1 | import { readdirSync, readFileSync, ensureDirSync } from 'fs-extra'; | 1 | import { readdirSync, readFileSync, ensureDirSync } from 'fs-extra'; |
2 | import { join } from 'node:path'; | 2 | import { join } from 'node:path'; |
3 | import { userDataCertsPath } from '../environment-remote'; | 3 | import { userDataCertsPath } from '../environment-remote'; |
4 | import { removeNewLines } from '../jsUtils'; | ||
4 | 5 | ||
5 | export function removeNewLines(string: string) { | 6 | export function checkIfCertIsPresent(certData: string): boolean { |
6 | return string.replaceAll(/\r?\n|\r/g, ''); | ||
7 | } | ||
8 | |||
9 | export function readCerts() { | ||
10 | const certsFolder = userDataCertsPath(); | 7 | const certsFolder = userDataCertsPath(); |
11 | 8 | ||
12 | ensureDirSync(certsFolder); | 9 | ensureDirSync(certsFolder); |
@@ -21,5 +18,5 @@ export function readCerts() { | |||
21 | certs.push(removeNewLines(cert)); | 18 | certs.push(removeNewLines(cert)); |
22 | } | 19 | } |
23 | 20 | ||
24 | return certs; | 21 | return certs.length > 0 && certs.includes(removeNewLines(certData)); |
25 | } | 22 | } |