Skip to content

Commit

Permalink
Update checkName.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Jun 28, 2024
1 parent 6dd97b4 commit 5d585ba
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/lib/util/checkName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@

// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
export function checkName(displayName: string, name: string, value: any): void {
if (!value) {
console.warn(`HAP-NodeJS WARNING: The accessory '${displayName}' is getting published with an empty '${name}'. This is not allowed.`);
return;
}

const validHK = /^[a-zA-Z0-9\s'-.]+$/; // Ensure only letter, numbers, apostrophe, or dash
const startWith = /^[a-zA-Z0-9]/; // Ensure only letters or numbers are at the beginning of string
const endWith = /[a-zA-Z0-9]$/; // Ensure only letters or numbers are at the end of string

if (!validHK.test(value) || !startWith.test(value) || !endWith.test(value)) {
if (typeof value !== "string" || !validHK.test(value) || !startWith.test(value) || !endWith.test(value)) {
console.warn("HAP-NodeJS WARNING: The accessory '" + displayName + "' is getting published with the characteristic '" +
name + "'" + " not following HomeKit naming rules ('" + value + "'). " +
"Use only alphanumeric, space, and apostrophe characters, start and end with an alphabetic or numeric character, and don't include emojis. " +
Expand Down

0 comments on commit 5d585ba

Please sign in to comment.