@hobenakicoffee/libraries 1.25.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { getNewsletterPostLink } from "./get-newsletter-post-link";
|
|
3
|
+
|
|
4
|
+
describe("getNewsletterPostLink", () => {
|
|
5
|
+
test("builds relative path without baseUrl", () => {
|
|
6
|
+
const result = getNewsletterPostLink("johndoe", "my-post");
|
|
7
|
+
expect(result).toBe("/@johndoe/posts/my-post");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("builds absolute URL with baseUrl", () => {
|
|
11
|
+
const result = getNewsletterPostLink(
|
|
12
|
+
"johndoe",
|
|
13
|
+
"my-post",
|
|
14
|
+
"https://hobenaki.coffee"
|
|
15
|
+
);
|
|
16
|
+
expect(result).toBe("https://hobenaki.coffee/@johndoe/posts/my-post");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("handles different usernames and slugs", () => {
|
|
20
|
+
expect(getNewsletterPostLink("alice", "welcome-newsletter")).toBe(
|
|
21
|
+
"/@alice/posts/welcome-newsletter"
|
|
22
|
+
);
|
|
23
|
+
expect(getNewsletterPostLink("bob", "updates-2024")).toBe(
|
|
24
|
+
"/@bob/posts/updates-2024"
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
});
|
package/src/utils/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./format-count";
|
|
|
4
4
|
export * from "./format-date";
|
|
5
5
|
export * from "./format-number";
|
|
6
6
|
export * from "./format-plain-text";
|
|
7
|
+
export * from "./get-newsletter-post-link";
|
|
7
8
|
export * from "./get-social-handle";
|
|
8
9
|
export * from "./get-social-link";
|
|
9
10
|
export * from "./get-user-name-initials";
|