Skip to content

Conversation

tor-nav
Copy link
Collaborator

@tor-nav tor-nav commented Aug 12, 2025

No description provided.

@tor-nav tor-nav requested a review from a team as a code owner August 12, 2025 10:34
@tor-nav tor-nav marked this pull request as draft August 12, 2025 10:34
msw: {
handlers: [
http.get(LosUrl.KODEVERK_LOS, () => HttpResponse.json(alleKodeverkLos)),
http.get(LosUrl.HENT_OPPGAVER_FOR_AVDELING.replace('ø', '%C3%B8'), () =>

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of '\u00f8'.

Copilot Autofix

AI 2 days ago

The problem should be fixed by ensuring all occurrences of the character ø in the string are replaced with the percent-encoded value %C3%B8. This is best accomplished using a regular expression with the global g flag, such as .replace(/ø/g, '%C3%B8'). Alternatively, the entire URL string could be encoded using encodeURI or encodeURIComponent (as appropriate), but if encoding only ø is desired, use of the global regex is most targeted, does not risk double-encoding already encoded bytes, and matches the original behavior. Change only line 57 of apps/fp-avdelingsleder/src/nokkeltall/fordelingAvBehandlingstype/FordelingAvBehandlingstypePanel.stories.tsx to .replace(/ø/g, '%C3%B8'). No new imports or definitions are needed.


Suggested changeset 1
apps/fp-avdelingsleder/src/nokkeltall/fordelingAvBehandlingstype/FordelingAvBehandlingstypePanel.stories.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/fp-avdelingsleder/src/nokkeltall/fordelingAvBehandlingstype/FordelingAvBehandlingstypePanel.stories.tsx b/apps/fp-avdelingsleder/src/nokkeltall/fordelingAvBehandlingstype/FordelingAvBehandlingstypePanel.stories.tsx
--- a/apps/fp-avdelingsleder/src/nokkeltall/fordelingAvBehandlingstype/FordelingAvBehandlingstypePanel.stories.tsx
+++ b/apps/fp-avdelingsleder/src/nokkeltall/fordelingAvBehandlingstype/FordelingAvBehandlingstypePanel.stories.tsx
@@ -54,7 +54,7 @@
     msw: {
       handlers: [
         http.get(LosUrl.KODEVERK_LOS, () => HttpResponse.json(alleKodeverkLos)),
-        http.get(LosUrl.HENT_OPPGAVER_FOR_AVDELING.replace('ø', '%C3%B8'), () =>
+        http.get(LosUrl.HENT_OPPGAVER_FOR_AVDELING.replace(/ø/g, '%C3%B8'), () =>
           HttpResponse.json(OPPGAVER_FOR_AVDELING),
         ),
       ],
EOF
@@ -54,7 +54,7 @@
msw: {
handlers: [
http.get(LosUrl.KODEVERK_LOS, () => HttpResponse.json(alleKodeverkLos)),
http.get(LosUrl.HENT_OPPGAVER_FOR_AVDELING.replace('ø', '%C3%B8'), () =>
http.get(LosUrl.HENT_OPPGAVER_FOR_AVDELING.replace(/ø/g, '%C3%B8'), () =>
HttpResponse.json(OPPGAVER_FOR_AVDELING),
),
],
Copilot is powered by AI and may make mistakes. Always verify output.
msw: {
handlers: [
http.get(LosUrl.KODEVERK_LOS, () => HttpResponse.json(alleKodeverkLos)),
http.get(LosUrl.HENT_OPPGAVER_PER_DATO.replace('ø', '%C3%B8'), () => HttpResponse.json(OPPGAVER_PER_DATO)),

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of '\u00f8'.

Copilot Autofix

AI 2 days ago

The best fix is to ensure that all occurrences of 'ø' in the URL string are replaced with '%C3%B8', not just the first. This can be accomplished by passing a regular expression to .replace with the global flag: .replace(/ø/g, '%C3%B8'). If the value being URL-encoded can contain more than just 'ø', it’s even safer to use a standard encoding library such as encodeURIComponent, but per the context, the code is just targeting 'ø'. The fix is a one-line change: replace the call .replace('ø', '%C3%B8') with .replace(/ø/g, '%C3%B8') on line 65 within apps/fp-avdelingsleder/src/nokkeltall/tilBehandling/TilBehandlingPanel.stories.tsx. No new imports are needed.

Suggested changeset 1
apps/fp-avdelingsleder/src/nokkeltall/tilBehandling/TilBehandlingPanel.stories.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/fp-avdelingsleder/src/nokkeltall/tilBehandling/TilBehandlingPanel.stories.tsx b/apps/fp-avdelingsleder/src/nokkeltall/tilBehandling/TilBehandlingPanel.stories.tsx
--- a/apps/fp-avdelingsleder/src/nokkeltall/tilBehandling/TilBehandlingPanel.stories.tsx
+++ b/apps/fp-avdelingsleder/src/nokkeltall/tilBehandling/TilBehandlingPanel.stories.tsx
@@ -62,7 +62,7 @@
     msw: {
       handlers: [
         http.get(LosUrl.KODEVERK_LOS, () => HttpResponse.json(alleKodeverkLos)),
-        http.get(LosUrl.HENT_OPPGAVER_PER_DATO.replace('ø', '%C3%B8'), () => HttpResponse.json(OPPGAVER_PER_DATO)),
+        http.get(LosUrl.HENT_OPPGAVER_PER_DATO.replace(/ø/g, '%C3%B8'), () => HttpResponse.json(OPPGAVER_PER_DATO)),
       ],
     },
   },
EOF
@@ -62,7 +62,7 @@
msw: {
handlers: [
http.get(LosUrl.KODEVERK_LOS, () => HttpResponse.json(alleKodeverkLos)),
http.get(LosUrl.HENT_OPPGAVER_PER_DATO.replace('ø', '%C3%B8'), () => HttpResponse.json(OPPGAVER_PER_DATO)),
http.get(LosUrl.HENT_OPPGAVER_PER_DATO.replace(/ø/g, '%C3%B8'), () => HttpResponse.json(OPPGAVER_PER_DATO)),
],
},
},
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
8 Security Hotspots
72.3% Duplication on New Code (required ≤ 10%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants