add url previewer in post content

This commit is contained in:
DefectingCat
2024-01-04 11:23:01 +08:00
parent 14c99275f7
commit d5607c0105
6 changed files with 120 additions and 7 deletions

View File

@ -152,3 +152,10 @@ export const frameArea = (
// point the camera to look at the center of the box
camera.lookAt(boxCenter.x, boxCenter.y, boxCenter.z);
};
export const isUrl = (url: string) => {
const urlRegex = new RegExp(
'^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$',
);
return urlRegex.test(url);
};