@hobenakicoffee/libraries 1.17.0 → 1.17.1
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
|
@@ -4,7 +4,6 @@ import { getUserPageLink } from "./get-user-page-link";
|
|
|
4
4
|
describe("getUserPageLink", () => {
|
|
5
5
|
test("builds user page link with sanitized username", () => {
|
|
6
6
|
const result = getUserPageLink(" @john doe ");
|
|
7
|
-
|
|
8
7
|
expect(result.endsWith("/@%40johndoe")).toBe(true);
|
|
9
8
|
});
|
|
10
9
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export function getUserPageLink(
|
|
1
|
+
export function getUserPageLink(
|
|
2
|
+
username: string,
|
|
3
|
+
baseUrl = "https://hobenakicoffee.com"
|
|
4
|
+
) {
|
|
2
5
|
const sanitizedUsername = encodeURIComponent(
|
|
3
6
|
username.trim().replace(/\s+/g, "")
|
|
4
7
|
);
|
|
5
|
-
return
|
|
8
|
+
return `${baseUrl}/@${sanitizedUsername}`;
|
|
6
9
|
}
|