Fix drag-performance (#1184)
* Fix drag-performance * Fixes * Fixes * Fixes * Fixes
This commit is contained in:
@ -37,7 +37,11 @@ describe('isURL', () => {
|
||||
expect(isURL('https://2.com/test/')).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should return false if string https://2.com/test/sldkfj!?`, () => {
|
||||
expect(isURL('https://2.com/test/sldkfj!?')).toBeFalsy();
|
||||
it(`should return true if string is https://www.linkedin.com/company/b%C3%B6ke-&-partner-sdft-partmbb/`, () => {
|
||||
expect(
|
||||
isURL(
|
||||
'https://www.linkedin.com/company/b%C3%B6ke-&-partner-sdft-partmbb/',
|
||||
),
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,14 +1,10 @@
|
||||
import { isDefined } from './isDefined';
|
||||
|
||||
export function isURL(url: string | undefined | null) {
|
||||
const pattern = new RegExp(
|
||||
'^(https?:\\/\\/)?' +
|
||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
|
||||
'((\\d{1,3}\\.){3}\\d{1,3}))' +
|
||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
|
||||
'(\\?[;&a-z\\d%_.~+=-]*)?' +
|
||||
'(\\#[-a-z\\d_]*)?$',
|
||||
'i',
|
||||
return (
|
||||
isDefined(url) &&
|
||||
url.match(
|
||||
/^(https?:\/\/)?(www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/i,
|
||||
)
|
||||
);
|
||||
return isDefined(url) && !!pattern.test(url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user