Add nprofile property to profile model

This commit is contained in:
Râu Cao 2025-04-30 12:21:51 +04:00
parent b7eccde9d0
commit 7aebcfc43f
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 16 additions and 1 deletions

View File

@ -59,6 +59,13 @@ export default class Profile {
return nip19.npubEncode(this.pubkey);
}
get nprofile(): string {
return nip19.nprofileEncode({
pubkey: this.pubkey,
relays: [config.relay_urls[0]],
});
}
get profileUrl(): string {
return `${config.base_url}/@${this.username}`;
}

View File

@ -69,7 +69,7 @@ describe("Article", () => {
describe("#naddr", () => {
it("returns a bech32 addressable event ID", () => {
expect(article.naddr).toMatch(
/naddr1qvzqqqr4gupzq8meqkx80g3yuklzymy0qf/,
/^naddr1qvzqqqr4gupzq8meqkx80g3yuklzymy0qf/,
);
});
});

View File

@ -40,4 +40,12 @@ describe("Profile", () => {
);
});
});
describe("#nprofile", () => {
it("returns a bech32 profile ID", () => {
expect(profile.nprofile).toMatch(
/^nprofile1qyt8wumn8ghj7mn0wd68ytntdaek6mmn9ehhyecqyq0hjpvvw73zfed7yf/,
);
});
});
});