mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:35:38 -04:00
Search: Add URL search inhibition logic
This commit is contained in:
parent
4c0b5c314d
commit
31a80420ec
@ -20,6 +20,9 @@ module Invidious::Search
|
|||||||
property region : String?
|
property region : String?
|
||||||
property channel : 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
|
# Return true if @raw_query is either `nil` or empty
|
||||||
private def empty_raw_query?
|
private def empty_raw_query?
|
||||||
return @raw_query.empty?
|
return @raw_query.empty?
|
||||||
@ -55,6 +58,13 @@ module Invidious::Search
|
|||||||
# Remove surrounding whitespaces. Mostly useful for copy/pasted URLs.
|
# Remove surrounding whitespaces. Mostly useful for copy/pasted URLs.
|
||||||
@raw_query = _raw_query.strip
|
@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)
|
# Get the page number (also common to all search types)
|
||||||
@page = params["page"]?.try &.to_i? || 1
|
@page = params["page"]?.try &.to_i? || 1
|
||||||
|
|
||||||
@ -140,6 +150,9 @@ module Invidious::Search
|
|||||||
|
|
||||||
# Checks if the query is a standalone URL
|
# Checks if the query is a standalone URL
|
||||||
def is_url? : Bool
|
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
|
# Only supported in regular search mode
|
||||||
return false if !@type.regular?
|
return false if !@type.regular?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user