Is it expected that the `page` helper returns a page without matching the given id _exactly_?

Consider a valid page with following slug blog/my-first-article that has a json content representation available next to the default html representation.

When using following code in a route: $p = page('blog/my-first-article.txt'), this returns the blog/my-first-article as $p. I can basically add anything behind a . and it still returns that page object. Is this expected? I would have expected a null tbh.

FYI: I currently worked around it like this

$p = null;
if (kirby()->call($slug)) {
    $p = page($slug);
}

Is this “bullet proof”?

Thanks

Extensions are indeed stripped from the id in the $pages->findById() method: kirby/Pages.php at 6b3cf988a6e773fd1d744045f3a0ab64b5ab129b · getkirby/kirby · GitHub

Nice find. I was not expecting this.

Is my “workaround” the way to go in this situation then?

As long as such a route doesn’t exist. But what I don’t quite get is where you would actually try to call the page helper with such an input?

I need to be able to render another content representation, based on URL-segment (and not extension) to work with an ESI setup in Varnish…