With PUBLIC_PATHS='code.digitaladapt.com/,code.digitaladapt.com/public/**', the home page (/) was not treated as public — only paths under /public/ worked.
Root Cause
In PublicPathMatcher::parse(), the host-prefix regex required at least one character after the slash:
The \/.+ meant that code.digitaladapt.com/ (where the path is just / with nothing after it) failed to match the regex. The entry then fell through to the str_starts_with($path, '/') check, but $path was still the full string code.digitaladapt.com/ (which doesn't start with /), so the pattern was silently dropped.
Fix
Changed \/.+ to \/.* so a trailing slash alone is accepted as the path /:
testDomainPrefixedRootPathMatchesRoot — verifies host/ matches / and nothing else
testDomainPrefixedRootWithOtherPatterns — reproduces the exact bug report scenario
All 295 tests pass.
## Bug
With `PUBLIC_PATHS='code.digitaladapt.com/,code.digitaladapt.com/public/**'`, the home page (`/`) was not treated as public — only paths under `/public/` worked.
## Root Cause
In `PublicPathMatcher::parse()`, the host-prefix regex required **at least one character after the slash**:
```php
if (preg_match('/^([a-z0-9.-]+)(\/.+)$/i', $entry, $m)) {
```
The `\/.+` meant that `code.digitaladapt.com/` (where the path is just `/` with nothing after it) failed to match the regex. The entry then fell through to the `str_starts_with($path, '/')` check, but `$path` was still the full string `code.digitaladapt.com/` (which doesn't start with `/`), so the pattern was silently dropped.
## Fix
Changed `\/.+` to `\/.*` so a trailing slash alone is accepted as the path `/`:
```php
if (preg_match('/^([a-z0-9.-]+)(\/.*)$/i', $entry, $m)) {
```
## Tests
Added two new test cases:
- `testDomainPrefixedRootPathMatchesRoot` — verifies `host/` matches `/` and nothing else
- `testDomainPrefixedRootWithOtherPatterns` — reproduces the exact bug report scenario
All 295 tests pass.
The host-prefix regex required at least one character after the slash
(/\+.+/), so a pattern like 'code.example.com/' was silently dropped
instead of matching the root path '/'. Changed \+.+ to \+.* so the
trailing slash alone is accepted as the path '/'.
Added tests covering the exact bug scenario from PUBLIC_PATHS
config: 'code.digitaladapt.com/,code.digitaladapt.com/public/**'
andrew
approved these changes 2026-08-13 15:42:29 -04:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Bug
With
PUBLIC_PATHS='code.digitaladapt.com/,code.digitaladapt.com/public/**', the home page (/) was not treated as public — only paths under/public/worked.Root Cause
In
PublicPathMatcher::parse(), the host-prefix regex required at least one character after the slash:The
\/.+meant thatcode.digitaladapt.com/(where the path is just/with nothing after it) failed to match the regex. The entry then fell through to thestr_starts_with($path, '/')check, but$pathwas still the full stringcode.digitaladapt.com/(which doesn't start with/), so the pattern was silently dropped.Fix
Changed
\/.+to\/.*so a trailing slash alone is accepted as the path/:Tests
Added two new test cases:
testDomainPrefixedRootPathMatchesRoot— verifieshost/matches/and nothing elsetestDomainPrefixedRootWithOtherPatterns— reproduces the exact bug report scenarioAll 295 tests pass.