import { always, cond } from 'ramda';

export interface QrCodeCapabilities {
  useSizeInPath: boolean;
  svgIsSupported: boolean;
}

export type QrCodeFormat = 'svg' | 'png';

export const buildQrCodeUrl = (
  shortUrl: string,
  size: number,
  format: QrCodeFormat,
  { useSizeInPath, svgIsSupported }: QrCodeCapabilities,
): string => {
  const sizeFragment = useSizeInPath ? `/${size}` : `?size=${size}`;
  const formatFragment = !svgIsSupported ? '' : `format=${format}`;
  const joinSymbolResolver = cond([
    [ () => useSizeInPath && svgIsSupported, always('?') ],
    [ () => !useSizeInPath && svgIsSupported, always('&') ],
  ]);
  const joinSymbol = joinSymbolResolver() ?? '';

  return `${shortUrl}/qr-code${sizeFragment}${joinSymbol}${formatFragment}`;
};

export interface QrCodeCapabilities {
  useSizeInPath: boolean;
  svgIsSupported: boolean;
}

export type QrCodeFormat = 'svg' | 'png';

export const buildQrCodeUrl = (
  shortUrl: string,
  size: number,
  format: QrCodeFormat,
  { useSizeInPath, svgIsSupported }: QrCodeCapabilities,
): string => {
  const sizeFragment = useSizeInPath ? `/${size}` : `?size=${size}`;
  const formatFragment = !svgIsSupported ? '' : `format=${format}`;
  const joinSymbol = useSizeInPath && svgIsSupported ? '?' : !useSizeInPath && svgIsSupported ? '&' : '';

  return `${shortUrl}/qr-code${sizeFragment}${joinSymbol}${formatFragment}`;
};

--- 
+++ 
@@ -1,3 +1,5 @@
+import { always, cond } from 'ramda';
+
 export interface QrCodeCapabilities {
   useSizeInPath: boolean;
   svgIsSupported: boolean;
@@ -13,7 +15,11 @@
 ): string => {
   const sizeFragment = useSizeInPath ? `/${size}` : `?size=${size}`;
   const formatFragment = !svgIsSupported ? '' : `format=${format}`;
-  const joinSymbol = useSizeInPath && svgIsSupported ? '?' : !useSizeInPath && svgIsSupported ? '&' : '';
+  const joinSymbolResolver = cond([
+    [ () => useSizeInPath && svgIsSupported, always('?') ],
+    [ () => !useSizeInPath && svgIsSupported, always('&') ],
+  ]);
+  const joinSymbol = joinSymbolResolver() ?? '';
 
   return `${shortUrl}/qr-code${sizeFragment}${joinSymbol}${formatFragment}`;
 };
Replace nested ternary conditions with ramda's cond
