Skip to content

Bug: pubkeyToHexColor throws on empty string, crashing template rendering #18

Description

@Priyanshubhartistm

Description

pubkeyToHexColor throws an Error when pubkey is an empty string. This function is called directly inside component template expressions (e.g., style="background-color: {pubkeyToHexColor(pubkey)}"). If the pubkey hasn't loaded yet, the component crashes.

File: src/lib/utils.nostr.ts

Affected Code

export function pubkeyToHexColor(pubkey: string): string {
  if (!pubkey) {
    throw new Error('Pubkey is required'); //  throws inside templates
  }
  return `#${pubkey.slice(0, 6)}`;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions