diff --git a/models/profile.ts b/models/profile.ts index f213fa0..b354c06 100644 --- a/models/profile.ts +++ b/models/profile.ts @@ -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}`; } diff --git a/tests/models/article_test.ts b/tests/models/article_test.ts index 4519ec7..6d52076 100644 --- a/tests/models/article_test.ts +++ b/tests/models/article_test.ts @@ -69,7 +69,7 @@ describe("Article", () => { describe("#naddr", () => { it("returns a bech32 addressable event ID", () => { expect(article.naddr).toMatch( - /naddr1qvzqqqr4gupzq8meqkx80g3yuklzymy0qf/, + /^naddr1qvzqqqr4gupzq8meqkx80g3yuklzymy0qf/, ); }); }); diff --git a/tests/models/profile_test.ts b/tests/models/profile_test.ts index 42d2e54..4c18a0c 100644 --- a/tests/models/profile_test.ts +++ b/tests/models/profile_test.ts @@ -40,4 +40,12 @@ describe("Profile", () => { ); }); }); + + describe("#nprofile", () => { + it("returns a bech32 profile ID", () => { + expect(profile.nprofile).toMatch( + /^nprofile1qyt8wumn8ghj7mn0wd68ytntdaek6mmn9ehhyecqyq0hjpvvw73zfed7yf/, + ); + }); + }); });