Fix drag-performance (#1184)

* Fix drag-performance

* Fixes

* Fixes

* Fixes

* Fixes
This commit is contained in:
Charles Bochet
2023-08-13 05:28:33 +02:00
committed by GitHub
parent bf09a4d6a2
commit e6b20b5ff2
25 changed files with 260 additions and 175 deletions

View File

@ -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();
});
});

View File

@ -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);
}