Follow-up from "Add prefix to autocomplete path"
<!--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>
- [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=335239)
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=335239)
</details>
<!--IssueSummary end-->
The following discussion from !65508 should be addressed:
- [ ] @tomquirk started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65508#note_619127355): (+1 comment)
> **suggestion (non-blocking)**: perhaps we could have a single function to build autocomplete paths, and use this every time we need an autocomplete endpoint:
>
> ```
> const autocompletePath = (filename = '') => `${gon.relative_url_root || ''}/-/autocomplete/${filename}`
> ```
issue