Skip to content

Add a warning if an optional segment isn't necessary due to a static route#772

Merged
bitspittle merged 4 commits intodevfrom
feature/dynamic-route-catchall-warning
Feb 12, 2026
Merged

Add a warning if an optional segment isn't necessary due to a static route#772
bitspittle merged 4 commits intodevfrom
feature/dynamic-route-catchall-warning

Conversation

@bitspittle
Copy link
Copy Markdown
Member

No description provided.

... where we will use it for readability as part of verifying
dynamic routes.
@bitspittle bitspittle force-pushed the feature/dynamic-route-catchall-warning branch from 5f6b7f5 to 662da7d Compare February 11, 2026 18:59
@bitspittle bitspittle force-pushed the feature/dynamic-route-catchall-warning branch 2 times, most recently from 89696bb to c3fa5e5 Compare February 11, 2026 21:39
}.forEach { entry ->
val parentDir = entry.route.substringBeforeLast('/').anonymizeDynamicSegments() + "/"
val finalSegment = entry.route.substringAfterLast('/')
val matchingStateEntry = entriesByRoute[parentDir]?.first()
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.

matchingStateEntry is a strange name, matchingRouteEntry maybe?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Whoops! It was supposed to be "matchingPageEntry" -- using "state" was just a brain fart. Thanks!

e.g. "/a/b/c/{d?}" when "/a/b/c/" is also registered.

At that point, we will issue an error telling
that the user drop the question mark, as in:

"/a/b/c/{d?}" -> "/a/b/c/{d}"

NOTE: A warning might have been more suitable for this case,
but this would cause the warning to get printed twice, once
when KSP processed the project and a second time when the Gradle
plugin merged the results from all sources. An error may be a
bit harsh, but there really is no reason I can see to define
an unecessary optional route.
@bitspittle bitspittle force-pushed the feature/dynamic-route-catchall-warning branch from fddc6d0 to 14cdfa9 Compare February 11, 2026 23:38
@bitspittle bitspittle merged commit 8240a0e into dev Feb 12, 2026
1 check passed
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.

2 participants