diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2024-02-13 21:46:12 +0100 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2024-08-17 19:22:40 +0200 |
| commit | 31a80420ec9f4dbd61a7145044f5e1797d4e0dd0 (patch) | |
| tree | bd2c852259a3c7ecad9b0b902e3421fdf2bc68bd /src | |
| parent | 4c0b5c314d68ea45e69de9673f0bf43bedf3acc4 (diff) | |
| download | invidious-31a80420ec9f4dbd61a7145044f5e1797d4e0dd0.tar.gz invidious-31a80420ec9f4dbd61a7145044f5e1797d4e0dd0.tar.bz2 invidious-31a80420ec9f4dbd61a7145044f5e1797d4e0dd0.zip | |
Search: Add URL search inhibition logic
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/search/query.cr | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/invidious/search/query.cr b/src/invidious/search/query.cr index f87c243e..b3db0f63 100644 --- a/src/invidious/search/query.cr +++ b/src/invidious/search/query.cr @@ -20,6 +20,9 @@ module Invidious::Search property region : String? property channel : String = "" + # Flag that indicates if the smart search features have been disabled. + @inhibit_ssf : Bool = false + # Return true if @raw_query is either `nil` or empty private def empty_raw_query? return @raw_query.empty? @@ -55,6 +58,13 @@ module Invidious::Search # Remove surrounding whitespaces. Mostly useful for copy/pasted URLs. @raw_query = _raw_query.strip + # Check for smart features (ex: URL search) inhibitor (exclamation mark). + # If inhibitor is present, remove it. + if @raw_query.starts_with?('!') + @inhibit_ssf = true + @raw_query = @raw_query[1..] + end + # Get the page number (also common to all search types) @page = params["page"]?.try &.to_i? || 1 @@ -140,6 +150,9 @@ module Invidious::Search # Checks if the query is a standalone URL def is_url? : Bool + # If the smart features have been inhibited, don't go further. + return false if @inhibit_ssf + # Only supported in regular search mode return false if !@type.regular? |
