-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Facebook links: display profile instead of full url #16414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
packages/twenty-front/src/utils/__tests__/getDisplayValueByUrlType.test.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
packages/twenty-front/src/utils/getDisplayValueByUrlType.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
packages/twenty-ui/src/utilities/utils/__tests__/getDisplayValueByUrlType.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| import { LinkType } from '@ui/navigation/link/components/SocialLink'; | ||
|
|
||
| import { getDisplayValueByUrlType } from '../getDisplayValueByUrlType'; | ||
|
|
||
| describe('getDisplayValueByUrlType', () => { | ||
| describe('linkedin', () => { | ||
| it('should extract username from LinkedIn profile URL', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'https://www.linkedin.com/in/johndoe', | ||
| }); | ||
| expect(result).toBe('johndoe'); | ||
| }); | ||
|
|
||
| it('should extract company name from LinkedIn company URL', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'https://www.linkedin.com/company/acme-corp', | ||
| }); | ||
| expect(result).toBe('acme-corp'); | ||
| }); | ||
|
|
||
| it('should extract school name from LinkedIn school URL', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'https://www.linkedin.com/school/mit', | ||
| }); | ||
| expect(result).toBe('mit'); | ||
| }); | ||
|
|
||
| it('should handle LinkedIn URL without protocol', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'linkedin.com/in/johndoe', | ||
| }); | ||
| expect(result).toBe('johndoe'); | ||
| }); | ||
|
|
||
| it('should handle LinkedIn URL without www', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'https://linkedin.com/in/johndoe', | ||
| }); | ||
| expect(result).toBe('johndoe'); | ||
| }); | ||
|
|
||
| it('should decode URL-encoded characters in LinkedIn username', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'https://www.linkedin.com/in/john%20doe', | ||
| }); | ||
| expect(result).toBe('john doe'); | ||
| }); | ||
|
|
||
| it('should return "LinkedIn" for invalid LinkedIn URLs', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.LinkedIn, | ||
| href: 'https://www.linkedin.com/feed', | ||
| }); | ||
| expect(result).toBe('LinkedIn'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('twitter', () => { | ||
| it('should extract username from Twitter URL with @ prefix', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Twitter, | ||
| href: 'https://www.twitter.com/johndoe', | ||
| }); | ||
| expect(result).toBe('@johndoe'); | ||
| }); | ||
|
|
||
| it('should handle Twitter URL without protocol', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Twitter, | ||
| href: 'twitter.com/johndoe', | ||
| }); | ||
| expect(result).toBe('@johndoe'); | ||
| }); | ||
|
|
||
| it('should handle Twitter URL without www', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Twitter, | ||
| href: 'https://twitter.com/johndoe', | ||
| }); | ||
| expect(result).toBe('@johndoe'); | ||
| }); | ||
|
|
||
| it('should return "@twitter" when no username can be extracted', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Twitter, | ||
| href: 'https://www.twitter.com', | ||
| }); | ||
| expect(result).toBe('@twitter'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('facebook', () => { | ||
| it('should extract username from Facebook profile URL', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Facebook, | ||
| href: 'https://www.facebook.com/johndoe', | ||
| }); | ||
| expect(result).toBe('johndoe'); | ||
| }); | ||
|
|
||
| it('should handle Facebook URL without protocol', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Facebook, | ||
| href: 'facebook.com/johndoe', | ||
| }); | ||
| expect(result).toBe('johndoe'); | ||
| }); | ||
|
|
||
| it('should handle Facebook URL without www', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Facebook, | ||
| href: 'https://facebook.com/johndoe', | ||
| }); | ||
| expect(result).toBe('johndoe'); | ||
| }); | ||
|
|
||
| it('should decode URL-encoded characters in Facebook username', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Facebook, | ||
| href: 'https://www.facebook.com/john%20doe', | ||
| }); | ||
| expect(result).toBe('john doe'); | ||
| }); | ||
|
|
||
| it('should return "Facebook" for invalid Facebook URLs', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Facebook, | ||
| href: 'https://www.facebook.com/', | ||
| }); | ||
| expect(result).toBe('Facebook'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('url type', () => { | ||
| it('should return undefined for generic url type', () => { | ||
| const result = getDisplayValueByUrlType({ | ||
| type: LinkType.Url, | ||
| href: 'https://example.com', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.