Follow-up from "Prefetch pathLastCommit GraphQL with StartupJS"
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=297663) </details> <!--IssueSummary end--> The following discussion from !51429 should be addressed: - [ ] [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51429#note_484069189): (+3 comments) > I'm a little bit hesitant about the combination: > > ```ruby > current_route_path = request.fullpath.match(/-\/tree\/[^\/]+\/(.+$)/).to_a[1] > path: current_route_path || "" > ``` > > I have two comments on that: > > 1. I see in the [GraphQL query annotation](https://gitlab.com/gitlab-org/gitlab/blob/a797ca35f0497fa2a2983e8e5c498bdb4fbd1ab9/app/graphql/queries/repository/path_last_commit.query.graphql) that the `path` is not required: > > `query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {` > > Maybe we can get away without the `|| ""` guard since it is allowed to be `nil`? > 1. Is there any way to test this logic? When I see regexp that I can't immediately understand, I usually look for unit tests to see what input/output am I working with.
issue