From a5b8b69080d20a2fb619b73fbaa31179b13abfee Mon Sep 17 00:00:00 2001
From: Tore Brede <Tore.Brede@uib.no>
Date: Wed, 6 Oct 2021 13:44:15 +0200
Subject: [PATCH] Removing some unintentional formatting changes

---
 frontend/src/utils/index.ts | 73 +++++++++++++++++++------------------
 1 file changed, 37 insertions(+), 36 deletions(-)

diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index f6b22dba..7264cc04 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -1,57 +1,58 @@
 import validator from '@navikt/fnrvalidator'
 import i18n from 'i18next'
-import { isValidPhoneNumber } from 'libphonenumber-js'
+import {isValidPhoneNumber} from 'libphonenumber-js'
 
 
 const valid_email_regex = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/
 
 export function getCookie(name: string) {
-  if (!document.cookie) {
-    return null
-  }
+    if (!document.cookie) {
+        return null
+    }
 
-  const cookies = document.cookie
-    .split(';')
-    .map((c) => c.trim())
-    .filter((c) => c.startsWith(`${name}=`))
+    const cookies = document.cookie
+        .split(';')
+        .map((c) => c.trim())
+        .filter((c) => c.startsWith(`${name}=`))
 
-  if (cookies.length === 0) {
-    return null
-  }
-  return decodeURIComponent(cookies[0].split('=')[1])
+    if (cookies.length === 0) {
+        return null
+    }
+    return decodeURIComponent(cookies[0].split('=')[1])
 }
 
 export function maybeCsrfToken() {
-  const csrfToken = getCookie('csrftoken')
-  if (!csrfToken) {
-    return null
-  }
-  return {
-    'X-CSRFToken': csrfToken,
-  }
+    const csrfToken = getCookie('csrftoken')
+    if (!csrfToken) {
+        return null
+    }
+    return {
+        'X-CSRFToken': csrfToken,
+    }
 }
 
 export function postJsonOpts(data: object): RequestInit {
-  return {
-    method: 'POST',
-    headers: {
-      'Content-Type': 'application/json',
-      ...maybeCsrfToken(),
-    },
-    body: JSON.stringify(data),
-    credentials: 'same-origin',
-  }
+    return {
+        method: 'POST',
+        headers: {
+            'Content-Type': 'application/json',
+            ...maybeCsrfToken(),
+        },
+        body: JSON.stringify(data),
+        credentials: 'same-origin',
+    }
 }
 
 export function isValidFnr(data: string | undefined): boolean | string {
-  if (data === null) {
-    return i18n.t<string>('common:validation.invalidIdNumber')
-  }
-  const valid = validator.idnr(data as string).status === 'valid'
-  if (valid) {
-    return true
-  }
-  return i18n.t<string>('common:validation.invalidIdNumber')
+    if (data === null) {
+        return i18n.t<string>('common:validation.invalidIdNumber').toString()
+    }
+    const valid = validator.idnr(data as string).status === 'valid'
+    if (valid) {
+        return true
+    }
+    // TypeScript complains if toString is not used on the function result
+    return i18n.t<string>('common:validation.invalidIdNumber').toString()
 }
 
 export function isValidMobilePhoneNumber(data: string | undefined): boolean | string {
-- 
GitLab