code refactoring

This commit is contained in:
2023-11-21 13:43:59 +01:00
parent 3f1f67b2c6
commit 12f6b6bf10

View File

@@ -18,49 +18,49 @@ const validateCookie = (cookie: string) => pipe(
cookie => cookie.replaceAll('\t', ' '), cookie => cookie.replaceAll('\t', ' '),
cookie => cookie.split(' '), cookie => cookie.split(' '),
E.of, E.of,
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f.length === 7, f => f.length === 7,
() => `missing parts` () => `missing parts`
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f[0].length > 0, f => f[0].length > 0,
() => 'missing domain' () => 'missing domain'
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f[1] === 'TRUE' || f[1] === 'FALSE', f => f[1] === 'TRUE' || f[1] === 'FALSE',
() => `invalid include subdomains` () => `invalid include subdomains`
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f[2].length > 0, f => f[2].length > 0,
() => 'invalid path' () => 'invalid path'
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f[3] === 'TRUE' || f[3] === 'FALSE', f => f[3] === 'TRUE' || f[3] === 'FALSE',
() => 'invalid secure flag' () => 'invalid secure flag'
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => isFinite(Number(f[4])), f => isFinite(Number(f[4])),
() => 'invalid expiration' () => 'invalid expiration'
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f[5].length > 0, f => f[5].length > 0,
() => 'invalid name' () => 'invalid name'
) )
), ),
E.chain( E.flatMap(
E.fromPredicate( E.fromPredicate(
f => f[6].length > 0, f => f[6].length > 0,
() => 'invalid value' () => 'invalid value'