Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/_utils/textExtraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const fetchReadableText = async (url: string): Promise<ExtractedContent>
try {
const response = await fetch(url, {
headers: {
'User-Agent': 'DumpItBot/1.0 (+https://dumpit-three.vercel.app)',
'User-Agent': `DumpItBot/1.0 (+${process.env.NEXT_PUBLIC_APP_URL || 'https://dumpit-three.vercel.app'})`,
Accept: 'text/html,text/plain;q=0.9,*/*;q=0.1',
},
redirect: 'follow',
Expand Down
19 changes: 14 additions & 5 deletions app/components/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export function Profile() {
const [shareByDefault, setShareByDefault] = useState(false)
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null)
const [copied, setCopied] = useState(false)
const [shareUrl, setShareUrl] = useState('')

const handleCopyLink = async () => {
if (!profile?.username) return
const link = `https://dumpit-three.vercel.app/u/${profile.username.toLowerCase()}`
if (!shareUrl) return
try {
await navigator.clipboard.writeText(link)
await navigator.clipboard.writeText(shareUrl)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
} catch (err) {
Expand All @@ -42,6 +42,15 @@ export function Profile() {
}
}, [user])

useEffect(() => {
if (profile?.username) {
const origin = typeof window !== 'undefined' ? window.location.origin : (process.env.NEXT_PUBLIC_APP_URL || 'https://dumpit-three.vercel.app')
setShareUrl(`${origin}/u/${profile.username.toLowerCase()}`)
} else {
setShareUrl('')
}
}, [profile])

const loadProfile = async () => {
if (!user) return
setLoading(true)
Expand Down Expand Up @@ -204,8 +213,8 @@ export function Profile() {
<p className="text-xs text-slate-500 dark:text-slate-400 mb-3">
Anyone can view your publicly shared resources by visiting your personal link.
</p>
<div className="app-muted-panel p-2 mb-3 truncate text-xs text-slate-600 dark:text-slate-300 select-all font-mono">
https://dumpit-three.vercel.app/u/{profile.username.toLowerCase()}
<div className="app-muted-panel p-2 mb-3 truncate text-xs text-slate-600 dark:text-slate-350 select-all font-mono">
{shareUrl || `.../u/${profile.username.toLowerCase()}`}
</div>
<div className="grid grid-cols-2 gap-2">
<button
Expand Down
16 changes: 13 additions & 3 deletions app/components/ui/ShareModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { Copy, Facebook, Linkedin, X } from 'lucide-react';
import { useState } from 'react';
import { useState, useEffect } from 'react';

interface ShareModalProps {
isOpen: boolean;
Expand All @@ -14,13 +14,23 @@ interface ShareModalProps {

export function ShareModal({ isOpen, onClose, resourceTitle, resourceNote, resourceLink, username }: ShareModalProps) {
const [copied, setCopied] = useState(false);
const [baseUrl, setBaseUrl] = useState('');

useEffect(() => {
if (typeof window !== 'undefined') {
setBaseUrl(window.location.origin);
} else {
setBaseUrl(process.env.NEXT_PUBLIC_APP_URL || 'https://dumpit-three.vercel.app');
}
}, []);

if (!isOpen) return null;

const resolvedBaseUrl = baseUrl || 'https://dumpit-three.vercel.app';
// Point to the user's public profile page if username is available, otherwise fallback to the resource's direct URL or the homepage
const publicLink = username
? `https://dumpit-three.vercel.app/u/${username.toLowerCase()}`
: (resourceLink || `https://dumpit-three.vercel.app/`);
? `${resolvedBaseUrl}/u/${username.toLowerCase()}`
: (resourceLink || `${resolvedBaseUrl}/`);
const userHandle = '@DumpItApp';

const handleTwitterShare = () => {
Expand Down
Loading