Skip to content

search: add github.com start anchor for literal patterns on dotcom

Administrator requested to merge rvt/not-slow-repo-resolve-with-globbing into main

Created by: rvantonder

An existing heuristic makes github.com/... patterns faster by prepending a start anchor ^ for sourcegraph.com. This heuristic assumes the github.com is a regex. However, a user (or query transformer) may escape the . before it gets to this function called in the resolve repos code, yielding github\.com/.... Because this string doesn't match the heuristic conditions, no ^ is prepended and so slow search behavior happens #12889.

This PR expands the heuristic conditions to also prepend a ^ when the . is escaped (we must still assume the input is regex until this logic is moved out of the resolve repo function, and into a query transformer, for which I've filed https://github.com/sourcegraph/sourcegraph/issues/12890)

No test since this is SourcegraphDotComMode specific, and straightforward enough.

Merge request reports

Loading