-
Notifications
You must be signed in to change notification settings - Fork 0
fix: ensure event urls that don't have http protocol also have them #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances URL handling in the EventCalendar component by ensuring all event URLs have a proper protocol (https://) for improved link reliability. The change addresses cases where event URLs might be missing the protocol, which could result in broken or non-functional links.
- Added a utility function
ensureHttpsProtocolto automatically prependhttps://to URLs missing a protocol - Updated both single and recurring event handling to use the new URL standardization function
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return `https://${trimmedUrl}`; | ||
| } | ||
|
|
||
| // For other cases (like relative paths), assume https:// |
Copilot
AI
Sep 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback logic incorrectly prepends https:// to relative paths, which will break them. Relative paths like /events/123 should be returned as-is, not converted to https:///events/123. Consider returning the original URL unchanged for relative paths or paths that don't match the domain pattern.
| // For other cases (like relative paths), assume https:// | |
| // For other cases (like relative paths), return as-is if it's a relative path | |
| if (trimmedUrl.startsWith("/")) { | |
| return trimmedUrl; | |
| } | |
| // Otherwise, prepend https:// |
| // If it starts with www. or looks like a domain, add https:// | ||
| if ( | ||
| trimmedUrl.startsWith("www.") || | ||
| /^[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z]{2,}/.test(trimmedUrl) | ||
| ) { | ||
| return `https://${trimmedUrl}`; | ||
| } | ||
|
|
||
| // For other cases (like relative paths), assume https:// | ||
| return `https://${trimmedUrl}`; |
Copilot
AI
Sep 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The domain validation regex is overly simplistic and may not handle all valid domain cases (e.g., domains with multiple subdomains, internationalized domains, or ports). Consider using a more robust URL validation approach or a well-tested URL parsing library.
| // If it starts with www. or looks like a domain, add https:// | |
| if ( | |
| trimmedUrl.startsWith("www.") || | |
| /^[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z]{2,}/.test(trimmedUrl) | |
| ) { | |
| return `https://${trimmedUrl}`; | |
| } | |
| // For other cases (like relative paths), assume https:// | |
| return `https://${trimmedUrl}`; | |
| // Try to parse as a valid URL; if it fails, prepend https:// and try again | |
| try { | |
| // Try parsing as is (may throw if missing protocol) | |
| new URL(trimmedUrl); | |
| // If no error, but no protocol, add https:// | |
| return `https://${trimmedUrl}`; | |
| } catch { | |
| try { | |
| // Try parsing with https:// prepended | |
| new URL(`https://${trimmedUrl}`); | |
| return `https://${trimmedUrl}`; | |
| } catch { | |
| // If still invalid, return original | |
| return trimmedUrl; | |
| } | |
| } |
This pull request enhances the handling of event URLs in the
EventCalendarcomponent to ensure all event links have a proper protocol, improving link reliability and user experience. The main focus is on standardizing URLs by automatically addinghttps://where needed.URL handling improvements:
Added a helper function
ensureHttpsProtocolinEventCalendar.tsxto prependhttps://to event URLs that are missing a protocol, ensuring all external links are valid and clickable.Updated the assignment of the
pageLinkproperty for both single and recurring events to use the newensureHttpsProtocolhelper, standardizing URL formatting throughout the calendar. [1] [2]### 📝 Description