mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Use kebab case instead of camel case
This commit is contained in:
21
framework/spree/utils/validate-cookie-expire.ts
Normal file
21
framework/spree/utils/validate-cookie-expire.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
const validateCookieExpire = (expire: unknown) => {
|
||||
let expireInteger: number
|
||||
|
||||
if (typeof expire === 'string') {
|
||||
expireInteger = parseFloat(expire || '')
|
||||
} else if (typeof expire === 'number') {
|
||||
expireInteger = expire
|
||||
} else {
|
||||
throw new TypeError(
|
||||
'expire must be a string containing a number or an integer.'
|
||||
)
|
||||
}
|
||||
|
||||
if (expireInteger < 0) {
|
||||
throw new RangeError('expire must be non-negative.')
|
||||
}
|
||||
|
||||
return expireInteger
|
||||
}
|
||||
|
||||
export default validateCookieExpire
|
Reference in New Issue
Block a user