From f77ab77db094b6548ce801850b3b798d3586869d Mon Sep 17 00:00:00 2001 From: Christian Hain <910645+XianHain@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:33:27 -0500 Subject: [PATCH] modify validation to support bluesky Discovered while testing #1909 This commit also uses pieces from #1872 that are related to the Bluesky property Refs: https://github.com/wesbos/awesome-uses/pull/1872 Refs: https://github.com/wesbos/awesome-uses/pull/1909 Co-authored-by: Kendall Morgan <1841529+kendallm@users.noreply.github.com> --- scripts/utils.js | 1 + src/components/Person.js | 8 ++++++++ src/data.js | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/utils.js b/scripts/utils.js index 4f936e65..489d021f 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -62,6 +62,7 @@ module.exports.Schema = Joi.object({ .required(), twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)), mastodon: Joi.string().pattern(new RegExp(/^@(\w){1,30}@(\w)+\.(.?\w)+$/)), + bluesky: Joi.string().pattern(new RegExp(/^[\w-]+\.(?:[\w-]+\.)?[\w-]+$/)), emoji: Joi.string().allow(''), computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'), phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'), diff --git a/src/components/Person.js b/src/components/Person.js index 21039a9f..b64118b9 100644 --- a/src/components/Person.js +++ b/src/components/Person.js @@ -151,5 +151,13 @@ Person.propTypes = { ); } }, + bluesky(props, propName, componentName) { + if (!/^(\w)+\.(\w)+\.(\w)+$/.test(props[propName])) { + return new Error( + `Invalid prop \`${propName}\` supplied to` + + ` \`${componentName}\`. This isn't a legit Bluesky handle.` + ); + } + }, }), }; diff --git a/src/data.js b/src/data.js index 45f2c3d4..c7ba9aa2 100644 --- a/src/data.js +++ b/src/data.js @@ -1,7 +1,7 @@ /** * @typedef Person * A single contributor with a /uses page. - * Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L68 + * Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L70 * @property {string} name - contributor's name * @property {string} description - tagline for contributor * @property {string} url - link to contributor's /uses page @@ -18,7 +18,7 @@ /** * List of all contributors with /uses pages. * @type {Person[]} - * Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L68 + * Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L70 * * Keep this a commonjs export. */