mirror of
https://github.com/dergigi/boris.git
synced 2026-02-23 07:54:59 +01:00
fix: improve URL regex patterns to prevent text artifacts
- Updated VideoEmbedProcessor regex patterns to use lookahead assertions - This prevents capturing HTML attribute syntax like quotes and angle brackets - Fixes text artifact appearing in UI when processing video URLs in HTML content
This commit is contained in:
@@ -31,7 +31,8 @@ const VideoEmbedProcessor = forwardRef<HTMLDivElement, VideoEmbedProcessorProps>
|
||||
const videoUrls: string[] = html.match(videoUrlPattern) || []
|
||||
|
||||
// Also check for video URLs that might not have extensions but are classified as video
|
||||
const allUrlPattern = /https?:\/\/[^\s<>"']+/gi
|
||||
// Use a more precise pattern that stops at whitespace, quotes, and HTML tag boundaries
|
||||
const allUrlPattern = /https?:\/\/[^\s<>"']+(?=\s|>|"|'|$)/gi
|
||||
const allUrls: string[] = html.match(allUrlPattern) || []
|
||||
const videoUrlsWithoutExt = allUrls.filter(url => {
|
||||
const classification = classifyUrl(url)
|
||||
@@ -62,7 +63,8 @@ const VideoEmbedProcessor = forwardRef<HTMLDivElement, VideoEmbedProcessorProps>
|
||||
const videoUrlPattern = /https?:\/\/[^\s<>"']+\.(mp4|webm|ogg|mov|avi|mkv|m4v)(?:\?[^\s<>"']*)?/gi
|
||||
const videoUrls: string[] = html.match(videoUrlPattern) || []
|
||||
|
||||
const allUrlPattern = /https?:\/\/[^\s<>"']+/gi
|
||||
// Use a more precise pattern that stops at whitespace, quotes, and HTML tag boundaries
|
||||
const allUrlPattern = /https?:\/\/[^\s<>"']+(?=\s|>|"|'|$)/gi
|
||||
const allUrls: string[] = html.match(allUrlPattern) || []
|
||||
const videoUrlsWithoutExt = allUrls.filter(url => {
|
||||
const classification = classifyUrl(url)
|
||||
|
||||
Reference in New Issue
Block a user