🐛 Fixed hyphen-separated permalink params#28129
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds a new matchPermalinkParams(permalinks, targetPath) helper that rewrites hyphen-separated permalink patterns so earlier :param tokens cannot greedily consume hyphens belonging to later tokens. entry-lookup now uses this helper to derive matched params from routerOptions.permalinks instead of calling path-match directly. Unit tests were added to verify correct param extraction and entryLookup flags (isEditURL, isUnknownOption) for date-based and generic hyphen-separated permalinks with hyphenated slugs. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
66f6a35 to
36521ad
Compare
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration |
✅ Succeeded | 1m 56s | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 7m 37s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 3m 4s | View ↗ |
nx build @tryghost/signup-form |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/activitypub |
✅ Succeeded | 2s | View ↗ |
nx build @tryghost/sodo-search |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/portal |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
Additional runs (7) |
✅ Succeeded | ... | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-05-26 14:54:32 UTC
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/test/unit/frontend/services/data/entry-lookup.test.js (1)
129-150: 💤 Low valueConsider asserting
lookup.entry.urlfor consistency.For consistency with existing tests (lines 61, 112, 124), consider adding an assertion:
assert.equal(lookup.entry.url, '/reportagem/2026-05-22-meu-cpf-foi-parar-na-totalpass/');This would strengthen the test by verifying the complete entry shape, not just the slug extraction.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ghost/core/test/unit/frontend/services/data/entry-lookup.test.js` around lines 129 - 150, Add an assertion to this test to verify the resolved entry's URL is correct: after the existing assertions in the it block for data.entryLookup (the dated permalinks case), assert that lookup.entry.url equals '/reportagem/2026-05-22-meu-cpf-foi-parar-na-totalpass/'; this complements the slug check on postsReadStub.firstCall.args[0].slug and ensures the returned entry shape includes the expected url property.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ghost/core/test/unit/frontend/services/data/entry-lookup.test.js`:
- Around line 129-150: Add an assertion to this test to verify the resolved
entry's URL is correct: after the existing assertions in the it block for
data.entryLookup (the dated permalinks case), assert that lookup.entry.url
equals '/reportagem/2026-05-22-meu-cpf-foi-parar-na-totalpass/'; this
complements the slug check on postsReadStub.firstCall.args[0].slug and ensures
the returned entry shape includes the expected url property.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f77b1c91-fcde-42d1-bc17-b96878acdd92
📒 Files selected for processing (2)
ghost/core/core/frontend/services/data/entry-lookup.jsghost/core/test/unit/frontend/services/data/entry-lookup.test.js
36521ad to
3dbd4f4
Compare
3dbd4f4 to
855b0b5
Compare
fixes #28076 path-to-regexp 1.9.0 changed how adjacent hyphen-separated params are captured through path-match. Constraining Ghost's known date tokens during entry lookup keeps existing dated permalink patterns working without pinning an archived transitive dependency.
855b0b5 to
30cccb2
Compare

fixes #28076
Summary
:section-:slugcase using fabricated URLsWhy this approach
path-matchdepends onpath-to-regexpvia a broad^1.0.0range, and the package is archived. Pinning the transitive dependency would restore the old behavior for now, but it keeps Ghost coupled to an unmaintained parser detail. This keeps the fix in Ghost by normalizing ambiguous hyphen-separated param segments before entry lookup.Testing
pnpm --dir ghost/core test:single test/unit/frontend/services/data/entry-lookup.test.js