fix: Fixed LinkedIn links with unicode (#3953)
* fix: Fixed LinkedIn links with unicode * feat: Added checkUrlType and getDisplayValueByUrlType util functions
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
import { checkUrlType } from '~/utils/checkUrlType';
|
||||
|
||||
describe('checkUrlType', () => {
|
||||
it('should return "linkedin", if linkedin url', () => {
|
||||
expect(checkUrlType('https://www.linkedin.com/in/håkan-fisk')).toBe(
|
||||
'linkedin',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "twitter", if twitter url', () => {
|
||||
expect(checkUrlType('https://www.twitter.com/john-doe')).toBe('twitter');
|
||||
});
|
||||
|
||||
it('should return "url", if neither linkedin nor twitter url', () => {
|
||||
expect(checkUrlType('https://www.example.com')).toBe('url');
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,40 @@
|
||||
import { LinkType } from '@/ui/navigation/link/components/SocialLink';
|
||||
import { getDisplayValueByUrlType } from '~/utils/getDisplayValueByUrlType';
|
||||
|
||||
describe('getDisplayValueByUrlType', () => {
|
||||
it('should return the linkedin username from the url', () => {
|
||||
expect(
|
||||
getDisplayValueByUrlType({
|
||||
type: LinkType.LinkedIn,
|
||||
href: 'https://www.linkedin.com/in/håkan-fisk',
|
||||
}),
|
||||
).toBe('håkan-fisk');
|
||||
expect(
|
||||
getDisplayValueByUrlType({
|
||||
type: LinkType.LinkedIn,
|
||||
href: 'https://www.linkedin.com/in/Matías',
|
||||
}),
|
||||
).toBe('Matías');
|
||||
expect(
|
||||
getDisplayValueByUrlType({
|
||||
type: LinkType.LinkedIn,
|
||||
href: 'https://www.linkedin.com/in/Mårten',
|
||||
}),
|
||||
).toBe('Mårten');
|
||||
expect(
|
||||
getDisplayValueByUrlType({
|
||||
type: LinkType.LinkedIn,
|
||||
href: 'https://www.linkedin.com/in/Sörvik',
|
||||
}),
|
||||
).toBe('Sörvik');
|
||||
});
|
||||
|
||||
it('should return the twitter username from the url', () => {
|
||||
expect(
|
||||
getDisplayValueByUrlType({
|
||||
type: LinkType.Twitter,
|
||||
href: 'https://www.twitter.com/john-doe',
|
||||
}),
|
||||
).toBe('@john-doe');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user