mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
search: trim trailing whitespace (#184)
When amfora is given a string to search, if that string contains a valid protocol (gemini://), and that string contains trailing whitespace, then the string is treated as a search term. Although perhaps slightly more uncommon, if the input string was as a result of copy/paste then it's possible the string could contain trailing spaces, which is not what was intended, but rather should be removed so that it's treated either as a valid gemini:// link or a search term. Some efforts around this appeared in #138
This commit is contained in:
parent
3111ac0bb0
commit
2f23390696
@ -198,6 +198,11 @@ func Init(version, commit, builtBy string) {
|
||||
} else {
|
||||
// It's a full URL or search term
|
||||
// Detect if it's a search or URL
|
||||
|
||||
// Remove whitespace from the string.
|
||||
// We don't want to convert legitimate
|
||||
// :// links to search terms.
|
||||
query := strings.TrimSpace(query)
|
||||
if (strings.Contains(query, " ") && !hasSpaceisURL.MatchString(query)) ||
|
||||
(!strings.HasPrefix(query, "//") && !strings.Contains(query, "://") &&
|
||||
!strings.Contains(query, ".")) && !strings.HasPrefix(query, "about:") {
|
||||
|
Loading…
Reference in New Issue
Block a user