Skip to content
Closed
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 KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Sources: [onboarding page](resources/js/pages/onboarding/show.tsx), [sign-in tes

### Profiles and GitHub sync

Every developer has a profile at `/@{username}`, with their GitHub identity, bio and other public profile information, commit/following/follower counts, and an activity graph. The Commits tab lists top-level commits; Replies lists that developer's replies with parent context. Follow and follower counts open the corresponding people lists. The profile links to GitHub and, when available, GitHub Sponsors. Share uses the device's share sheet when supported, or copies the profile link.
Every developer has a profile at `/@{username}`, with their GitHub identity, bio and other public profile information, commit/following/follower counts, and an activity graph. The Commits tab lists top-level commits; Replies lists that developer's replies with parent context. Follow and follower counts open the corresponding people lists. URLs in profile bios are highlighted and clickable, using the same link formatting as commits. The profile links to GitHub and, when available, GitHub Sponsors. Share uses the device's share sheet when supported, or copies the profile link.

Change your name, avatar, bio, company, location, or website on GitHub, not on /dev/null. Settings → Profile offers **Edit on GitHub** and **Sync from GitHub**. Profile details also refresh on sign-in. Manual sync is limited to once a minute. A GitHub username rename is picked up on sign-in; accounts are not merged with another user's account.

Expand Down
13 changes: 13 additions & 0 deletions resources/js/components/profile-bio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { LinkifiedText } from '@/components/linkified-text';

export function ProfileBio({ bio }: { bio: string | null }) {
if (!bio) {
return null;
}

return (
<p className="mt-3 max-w-prose text-[15px] leading-relaxed wrap-break-word whitespace-pre-wrap">
<LinkifiedText text={bio} mentions={null} />
</p>
);
}
7 changes: 2 additions & 5 deletions resources/js/pages/user/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import { PageTabs } from '@/components/page-tabs';
import { PinCommitButton } from '@/components/pin-commit-button';
import { ProfileActionsMenu } from '@/components/profile-actions-menu';
import { ProfileBio } from '@/components/profile-bio';
import { ProfileShareButton } from '@/components/profile-share-button';
import { Button } from '@/components/ui/button';
import { UserAvatar } from '@/components/user-avatar';
Expand Down Expand Up @@ -244,11 +245,7 @@ export default function Show({
</button>
</div>

{user.bio && (
<p className="mt-3 max-w-prose text-[15px] leading-relaxed wrap-break-word whitespace-pre-wrap">
{user.bio}
</p>
)}
<ProfileBio bio={user.bio} />

<ul className="mt-3 flex flex-wrap gap-x-4 gap-y-1.5 text-sm text-muted-foreground">
{user.company && (
Expand Down
100 changes: 100 additions & 0 deletions tests/Unit/ProfileBio.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/// <reference types="node" />
import assert from 'node:assert/strict';
import { renderToStaticMarkup } from 'react-dom/server';
import { test } from 'vite-plus/test';
import { ProfileBio } from '../../resources/js/components/profile-bio';

for (const bio of [null, '']) {
test(`omits an empty bio: ${bio}`, () => {
assert.equal(renderToStaticMarkup(<ProfileBio bio={bio} />), '');
});
}

test('preserves plain text, mentions and line breaks in a bio', () => {
const bio = 'Building with @laravel.\nEmail hello@example.com';
const markup = renderToStaticMarkup(<ProfileBio bio={bio} />);

assert.equal(markup.replace(/<[^>]+>/g, ''), bio);
assert.ok(markup.includes('whitespace-pre-wrap'));
assert.ok(!markup.includes('<a'));
});

test('highlights explicit URLs and bare domains with safe external links', () => {
const markup = renderToStaticMarkup(
<ProfileBio bio="Building https://example.com/docs and laravel.com." />,
);

assert.equal((markup.match(/<a /g) ?? []).length, 2);
for (const href of ['https://example.com/docs', 'https://laravel.com']) {
assert.ok(markup.includes(`href="${href}"`));
}
assert.equal((markup.match(/target="_blank"/g) ?? []).length, 2);
assert.equal(
(markup.match(/rel="noopener noreferrer nofollow ugc"/g) ?? []).length,
2,
);
assert.equal(
(markup.match(/text-primary hover:underline/g) ?? []).length,
2,
);
assert.ok(markup.endsWith('</a>.</p>'));
});

test('escapes HTML and leaves unsafe schemes as text', () => {
const markup = renderToStaticMarkup(
<ProfileBio bio="<script>alert(1)</script> javascript:alert(1)" />,
);

assert.ok(markup.includes('&lt;script&gt;alert(1)&lt;/script&gt;'));
assert.ok(!markup.includes('<script'));
assert.ok(!markup.includes('<a'));
});

for (const [text, href] of [
['example.com', 'https://example.com'],
['www.example.com', 'https://www.example.com'],
['http://example.com', 'http://example.com'],
['https://example.com', 'https://example.com'],
['http://www.example.com', 'http://www.example.com'],
['https://www.example.com', 'https://www.example.com'],
['HTTPS://example.com', 'HTTPS://example.com'],
['example.dev', 'https://example.dev'],
['example.io', 'https://example.io'],
['example.co.uk', 'https://example.co.uk'],
['www.example.com/about', 'https://www.example.com/about'],
['example.com?q=hello#bio', 'https://example.com?q=hello#bio'],
['https://dev-null.sh', 'https://dev-null.sh'],
['http://localhost:8000', 'http://localhost:8000'],
['https://example.com/docs_(guide)', 'https://example.com/docs_(guide)'],
]) {
test(`links a bio URL written as ${text}`, () => {
const markup = renderToStaticMarkup(
<ProfileBio bio={`See (${text}).`} />,
);

assert.equal((markup.match(/<a /g) ?? []).length, 1);
assert.ok(markup.includes(`href="${href}"`));
assert.ok(markup.startsWith('<p class="'));
assert.ok(markup.endsWith('</a>).</p>'));
});
}

for (const text of [
'hello@example.com',
'hello@www.example.com',
'@laravel',
'@inertiajs/react',
'javascript:alert(1)',
'data:text/html,<script>alert(1)</script>',
'file:///etc/passwd',
'http://',
'https://',
'app.name',
'index.php',
]) {
test(`leaves non-URL bio text unlinked: ${text}`, () => {
const markup = renderToStaticMarkup(<ProfileBio bio={text} />);

assert.ok(!markup.includes('<a'));
});
}
1 change: 1 addition & 0 deletions tests/draft-images.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default defineConfig({
'tests/Unit/TabSlide.test.tsx',
'tests/Unit/ReportResolution.test.tsx',
'tests/Unit/LinkifiedText.test.tsx',
'tests/Unit/ProfileBio.test.tsx',
],
},
});
1 change: 1 addition & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"include": [
"Unit/**/*.test.ts",
"Unit/DraftStash.test.tsx",
"Unit/ProfileBio.test.tsx",
"Unit/ComposerDraft.test.tsx",
"Unit/SearchDialogComposition.test.tsx",
"Unit/DraftImageReads.test.tsx",
Expand Down