Fix array and links display (#8671)
## Before   ## After  
This commit is contained in:
@ -5,10 +5,17 @@ describe('checkUrlType', () => {
|
||||
expect(checkUrlType('https://www.linkedin.com/in/håkan-fisk')).toBe(
|
||||
'linkedin',
|
||||
);
|
||||
expect(checkUrlType('http://www.linkedin.com/in/håkan-fisk')).toBe(
|
||||
'linkedin',
|
||||
);
|
||||
expect(checkUrlType('https://linkedin.com/in/håkan-fisk')).toBe('linkedin');
|
||||
expect(checkUrlType('http://linkedin.com/in/håkan-fisk')).toBe('linkedin');
|
||||
expect(checkUrlType('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');
|
||||
expect(checkUrlType('https://www.x.com/john-doe')).toBe('twitter');
|
||||
});
|
||||
|
||||
it('should return "url", if neither linkedin nor twitter url', () => {
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
import { LinkType } from 'twenty-ui';
|
||||
import { isDefined } from './isDefined';
|
||||
|
||||
export const checkUrlType = (url: string) => {
|
||||
if (
|
||||
/^(http|https):\/\/(?:www\.)?linkedin.com(\w+:{0,1}\w*@)?(\S+)(:([0-9])+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(
|
||||
url,
|
||||
)
|
||||
) {
|
||||
if (/^(https?:\/\/)?(www\.)?linkedin\.com\/.+$/.test(url)) {
|
||||
return LinkType.LinkedIn;
|
||||
}
|
||||
if (
|
||||
isDefined(/^((http|https):\/\/)?(?:www\.)?twitter\.com\/(\w+)?/i.exec(url))
|
||||
) {
|
||||
if (/^(https?:\/\/)?(www\.)?twitter\.com\/.+$/.test(url)) {
|
||||
return LinkType.Twitter;
|
||||
}
|
||||
if (/^(https?:\/\/)?(www\.)?x\.com\/.+$/.test(url)) {
|
||||
return LinkType.Twitter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user