forked from ShelterTechSF/askdarcel-web
-
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
Merged
Merged
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
09def26
map exploration, hide expired events, fix weback
chadbrokaw 7060df9
Temporarily disable tests
chadbrokaw bb76f95
Revert webpack change
chadbrokaw 5f0c362
Improve Search Header
chadbrokaw c64b311
fix: fix tests and cleanup code
chadbrokaw cb0661a
reenable tests
chadbrokaw 3a40297
refactor: remove unused zoom change listener from SearchMap component
chadbrokaw 9eb8bd6
fix: Fix BrowseResultsPage
chadbrokaw da2654a
fix: add some logging
chadbrokaw e4b1d20
fix: remove console log
chadbrokaw dc538be
attempt to fix category switching issue
chadbrokaw bac8449
Don't reset map init
chadbrokaw 4d4e3c9
fix: remove logging
chadbrokaw a35790a
Pulling events from Open Data Portal
chadbrokaw baf1c5b
fix: add days of week and allow for series of events
chadbrokaw 35929c7
fix: refresh styles
chadbrokaw 1502628
fix: test
chadbrokaw 38d53f3
fix: remove exploration work for eligibility filtering
chadbrokaw ef753be
fix: Fix some visual inconsistencies and bugs
chadbrokaw 26c1577
rename featued events and shuffle homepage order
chadbrokaw b8d6546
fix: calendar section background color
chadbrokaw 26613a6
Remove commented code
chadbrokaw 0b20179
Merge branch 'main' into development
chadbrokaw d5f8563
Merge branch 'main' into development
chadbrokaw b3b9fae
fix: ensure https protocol
chadbrokaw 836539b
fix: make it more robust and add security considerations
chadbrokaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -103,6 +103,29 @@ const shouldEventOccurOnDay = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| return days.some((day) => dayMap[day] === dayOfWeek); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Helper function to ensure URLs have proper protocol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ensureHttpsProtocol = (url: string): string => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!url || url.trim() === "") return url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const trimmedUrl = url.trim(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If it already has a protocol, return as is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (trimmedUrl.startsWith("http://") || trimmedUrl.startsWith("https://")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return trimmedUrl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 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}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 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; | |
| } | |
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/123should be returned as-is, not converted tohttps:///events/123. Consider returning the original URL unchanged for relative paths or paths that don't match the domain pattern.