Skip to content

Commit

Permalink
Merge branch 'preview'
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelfan committed Dec 16, 2023
2 parents 8636e74 + 6978a31 commit ef4e20f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/dataDisplay/profileBio/ProfileBio.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { getHandle } from "@/lib/utils/text";
import { getHandle, getHostname, getShortAddress } from "@/lib/utils/text";
import { RichText as RichTextHelper } from "@atproto/api";
import Link from "next/link";
import { Fragment } from "react";
Expand Down Expand Up @@ -40,13 +40,13 @@ export default function ProfileBio(props: Props) {
text: segment.text,
component: (
<Link
className="text-primary break-all hover:text-primary-dark"
href={segment.link?.uri!}
className="inline-block text-primary break-all hover:text-primary-dark"
href={segment.link!.uri}
target="blank"
key={segment.link?.uri}
key={segment.link!.uri}
onClick={(e) => e.stopPropagation()}
>
{segment.text}
{getShortAddress(segment.link!.uri)}
</Link>
),
});
Expand Down
12 changes: 11 additions & 1 deletion src/lib/utils/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BskyAgent, RichText } from "@atproto/api";
import { JSONContent } from "@tiptap/react";

export function getHandle(mention: string) {
Expand All @@ -16,6 +15,17 @@ export function getHostname(url: string) {
return matches ? matches[1] : url.replace(/^www\./, "");
}

export function getShortAddress(url: string) {
const newURL = new URL(url);
const text = newURL.hostname + newURL.pathname;

if (text.endsWith("/")) {
return text.slice(0, -1);
}

return text;
}

export function getNotificationLabel(reason: string) {
switch (reason) {
case "like":
Expand Down

0 comments on commit ef4e20f

Please sign in to comment.