fix: expand Intercom allowed URLs and prevent double-prefixing #25181
+28
−4
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.
What does this PR do?
Fixes two issues with the Intercom app integration:
/team/or/org/prefixeshttps://grow-therapy.cal.com/provider-billing-support/grow-therapy-callbackwere being incorrectly prefixed withapp.cal.com, resulting in malformed URLs likehttps://app.cal.com/https://grow-therapy.cal.com/...Changes Made
1. URL Validation (
packages/app-store/intercom/lib/isValidCalURL.ts)(team/)?(org/)?pattern from regexhttps://[subdomain.]cal.com/...2. URL Parsing (
packages/app-store/intercom/api/get.ts)cal.comor*.cal.comdomains only3. URL Encoding (
packages/app-store/intercom/api/initialize.ts)encodeURIComponentwhen passing URLs as query parametersSupported URL Patterns
The integration now supports:
https://app.cal.com/username/event-typehttps://cal.com/username/event-typehttps://subdomain.cal.com/username/event-type(any subdomain)https://cal.com/team/teamname/event-type/username/event-typeLink to Devin run: https://app.devin.ai/sessions/4d063aa5a62b40839c9f15f129ff6976
Requested by: @PeerRich ([email protected])
Slack thread: https://calendso.slack.com/archives/C08LT9BLEET/p1763194297107149
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Prerequisites:
grow-therapy.cal.com)Test Cases:
Test absolute URL with subdomain:
https://grow-therapy.cal.com/provider-billing-support/grow-therapy-callbackapp.cal.comTest various URL patterns:
https://app.cal.com/username/30minhttps://cal.com/username/meetinghttps://subdomain.cal.com/team/teamname/event-typeTest relative paths (backward compatibility):
/username/event-typeapp.cal.comas originTest invalid URLs (security):
https://malicious.com/fake-pathHuman Review Checklist
URL parsing logic in
get.ts(lines 19-38)/^https?:\/\//icorrectly identify absolute URLs?hostname.endsWith(".cal.com")match unintended domains?Cal embed API usage (lines 83-91)
Cal("init")andCal("inline")?originparameter?parsedUrl.searchincalLink?Regex change in
isValidCalURL.tsTesting gaps
Potential breaking changes
/team/or/org/restriction break?Checklist