Files
klz-cables.com/.pnpm-store/v10/files/bd/570e624bab5b19addb0cf4367c5f32667f9d87a8587fe0de13471cc8fda8244fe881f814770d3241f4e8fef5efa7c03c0c9f3a4ac047002d60ec3d1a610d5e
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

34 lines
1.6 KiB
Plaintext

import { GraphQLScalarType, Kind } from 'graphql';
import { createGraphQLError } from '../error.js';
const BCP_47_REGEX = /^(((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$/;
function validate(value, ast) {
if (!value) {
throw createGraphQLError(`Value is not a valid string. Received: ${value}`, ast ? { nodes: ast } : undefined);
}
const isValidFormat = BCP_47_REGEX.test(value);
if (!isValidFormat) {
throw createGraphQLError(`Value is not a valid BCP-47 standard formatted string. Received: ${value}`, ast ? { nodes: ast } : undefined);
}
return value;
}
export const GraphQLLocale = /*#__PURE__*/ new GraphQLScalarType({
name: 'Locale',
description: 'The locale in the format of a BCP 47 (RFC 5646) standard string',
serialize: validate,
parseValue: validate,
parseLiteral(ast) {
if (ast.kind === Kind.STRING) {
return validate(ast.value, ast);
}
throw createGraphQLError(`Value is not a string. Received: ${ast.kind}`, { nodes: ast });
},
extensions: {
codegenScalarType: 'string',
jsonSchema: {
title: 'Locale',
type: 'string',
pattern: BCP_47_REGEX.source,
},
},
});