Skip to content

fix(rest): match brand site URLs with or without a trailing slash, and read validated REST params - #387

Open
justlevine wants to merge 5 commits into
mainfrom
fix/site-url-backports
Open

justlevine wants to merge 5 commits into
mainfrom
fix/site-url-backports

Conversation

@justlevine

@justlevine justlevine commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Brand site URLs that only differ by a trailing slash now count as the same site. The REST save rejects them as duplicates, and editing a brand site's URL to add or drop the slash no longer asks for the API key again.
  • The /shared-sites and /algolia-credentials callbacks now read the params the route already validated, so a save works the same whether it's sent as JSON or as a form.

Why

The duplicate check compared raw URLs, so https://brand.com and https://brand.com/ could both get saved, with one hiding the other. The site modal did the same, so removing the slash while editing asked for a new API key and failed to save without one.

The callbacks ignored the validated params and read the raw JSON body. A form-encoded save to /shared-sites passed validation, decoded to nothing, and wiped every brand site with a 200. A form-encoded save to /algolia-credentials failed with "Both App ID and Write Key are required."

Related Issue(s):

How

  • URLs go through Utils::normalize_url() in the controller and Settings (instead of a mix of that and trailingslashit()), and SiteModal compares them with withTrailingSlash() like OneDesign does.
  • The callbacks read $request['sites_data'], $request['app_id'] and $request['write_key'].

AI Disclosure

Opus 5.5 identified the mismatched and backported the initial version and draft PR description.

Testing Instructions

Screenshots

Additional Info

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

Copilot AI balanced review requested due to automatic review settings November 16, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.78%. Comparing base (2b01585) to head (2e8713d).

Files with missing lines Patch % Lines
assets/src/components/SiteModal.tsx 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #387      +/-   ##
============================================
- Coverage     90.82%   90.78%   -0.04%     
+ Complexity      889      887       -2     
============================================
  Files            51       51              
  Lines          3336     3333       -3     
  Branches        181      182       +1     
============================================
- Hits           3030     3026       -4     
  Misses          255      255              
- Partials         51       52       +1     
Flag Coverage Δ
unit 91.84% <100.00%> (-0.02%) ⬇️
vitest 86.21% <50.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nc/Modules/Rest/Algolia_Credentials_Controller.php 65.90% <100.00%> (-0.76%) ⬇️
inc/Modules/Rest/Shared_Sites_Controller.php 97.22% <100.00%> (ø)
inc/Modules/Settings/Settings.php 86.28% <100.00%> (-0.24%) ⬇️
assets/src/components/SiteModal.tsx 75.80% <50.00%> (-1.25%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justlevine
justlevine requested a review from Kallyan01 November 16, 2026 16:08

@Kallyan01 Kallyan01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justlevine, the URL input doesn't trim leading or trailing spaces when pasted, which breaks the connection. Also, anyone can modify the URL without needing to provide any key.

Screen.Recording.2026-11-17.at.13.52.22.mov

@justlevine
justlevine requested a review from Kallyan01 November 17, 2026 17:51
@justlevine

Copy link
Copy Markdown
Collaborator Author

@justlevine, the URL input doesn't trim leading or trailing spaces when pasted, which breaks the connection. Also, anyone can modify the URL without needing to provide any key.

Thanks @Kallyan01 , fixed in 2e8713d . Looks like that issue also affects onedesign, so I'm backporting to there too.

@justlevine justlevine mentioned this pull request Nov 17, 2026
7 tasks done

@Kallyan01 Kallyan01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants