Skip to content

Commit

Permalink
fix: remove trailing newlines in patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed Aug 28, 2024
1 parent e5b5a56 commit 81fa39c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gh-find-code
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,14 @@ gh_query() {
# processing these patterns later, split on \x1f, which is equivalent to the \u001F.
# https://condor.depaul.edu/sjost/lsp121/documents/ascii-npr.htm
# https://datatracker.ietf.org/doc/html/rfc20#section-4.1
patterns: ([.value.text_matches[] | .. | .text? | select(type=="string")] as $patterns_array |
patterns: ([.value.text_matches[] | .. | .text? | select(type=="string") | sub("\n$"; "")] as $patterns_array |
if $patterns_array == [] then "__NoPatternFound__" else $patterns_array | unique | join("\u001F") end)
# Separating the fields with the Record Separator (RS). '@tsv' is not suitable because it
# double-escapes escaped characters. '@sh' is also not viable as it uses spaces as
# delimiters, which cannot be reliably used since file paths can contain spaces.
# Separating the fields with the Record Separator (RS). @tsv is not suitable because it
# double-escapes escaped characters. The @tsv had the advantage of printing its input as a
# single line, thus it is necessary to remove trailing newline characters from patterns. @sh
# is also not viable as it uses spaces as delimiters, which cannot be reliably used since
# file paths can contain spaces.
} | [.index, .owner_repo_name, .file_name, .file_path, .patterns] | join("\u001e"))' \
2>"$store_gh_search_error") || [[ -z $data ]]; then
if grep --quiet --ignore-case "API rate limit exceeded" "$store_gh_search_error"; then
Expand Down

0 comments on commit 81fa39c

Please sign in to comment.