Skip to content

Commit

Permalink
No escapes, but give margins for upper limits
Browse files Browse the repository at this point in the history
  • Loading branch information
snaka committed Aug 7, 2024
1 parent a7b075d commit bbcd48b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tagpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,14 @@ func buildChunkSearchIssuesQuery(qualifiers string, shasStr string) (chunkQuerie
continue
}
// Longer than 256 characters are not supported in the query.
// Note that the length limit does not include the qualifiers (ex. "repo:owner/repo", "is:close").
// ref. https://docs.github.com/en/rest/reference/search#limitations-on-query-length
//
// Also, from the results of the experiment, it is possible that when counting
// the number of characters in the keyword part, one space character is counted
// as three characters (possibly '%20').
if len(strings.Join(keywords, "%20") + "%20" + sha) >= 256 {
// However, although not explicitly stated in the documentation, the space separating
// keywords is counted as one or more characters, so it is possible to exceed 256
// characters if the text is filled to the very limit of 256 characters.
// For this reason, the maximum number of chars in the KEYWORD section is limited here to 200.
tempKeywords := append(keywords, sha)
if len(strings.Join(tempKeywords, " ")) >= 200 {
chunkQueries = append(chunkQueries, qualifiers + " " + strings.Join(keywords, " "))
keywords = make([]string, 0, 25)
}
Expand Down

0 comments on commit bbcd48b

Please sign in to comment.