mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Replace nested ternary conditions with ramda's cond
This commit is contained in:
parent
e2ba63ff58
commit
ecefa22204
1 changed files with 7 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import { always, cond } from 'ramda';
|
||||
|
||||
export interface QrCodeCapabilities {
|
||||
useSizeInPath: boolean;
|
||||
svgIsSupported: boolean;
|
||||
|
@ -13,7 +15,11 @@ export const buildQrCodeUrl = (
|
|||
): 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}`;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue