replace == "" with .blank?

This commit is contained in:
Jill 2023-01-04 15:05:27 +03:00
parent 8ce08f0b79
commit 1cc00624fe
5 changed files with 7 additions and 7 deletions

View File

@ -19,7 +19,7 @@ CrystalGauntlet.endpoints["/uploadGJComment21.php"] = ->(context : HTTP::Server:
return "-1"
end
if comment && comment != ""
if comment && !comment.blank?
# todo: cap comment size
comment_value = Base64.decode_string comment # usual b64, surprisingly
next_id = IDs.get_next_id("comments")

View File

@ -23,7 +23,7 @@ CrystalGauntlet.endpoints["/getGJLevels21.php"] = ->(context : HTTP::Server::Con
searchQuery = params["str"]? || ""
if searchQuery != "" && params["type"] != "5" && params["type"] != "10" && params["type"] != "19"
if !searchQuery.blank? && params["type"] != "5" && params["type"] != "10" && params["type"] != "19"
if searchQuery.to_i?
# we do this to get rid of the initial "unlisted = 0" bit
can_see_unlisted = true
@ -59,7 +59,7 @@ CrystalGauntlet.endpoints["/getGJLevels21.php"] = ->(context : HTTP::Server::Con
# $params[] = "levelID IN ($completedLevels)";
end
if params["song"]?
if params["customSong"]? && params["customSong"]? != ""
if params["customSong"]? && !params["customSong"].blank?
queryParams << "song_id = '#{params["customSong"].to_i}'"
else
queryParams << "song_id = '#{params["song"].to_i}'"

View File

@ -13,7 +13,7 @@ CrystalGauntlet.endpoints["/uploadGJAccComment20.php"] = ->(context : HTTP::Serv
comment = params["comment"]?
if comment && comment != ""
if comment && !comment.blank?
# todo: cap comment size
comment_value = Base64.decode_string comment # usual b64, surprisingly
next_id = IDs.get_next_id("account_comments")

View File

@ -17,7 +17,7 @@ module CrystalGauntlet::Accounts
# DOESN'T VERIFY PASSWORD
def get_ext_id_from_params(params : URI::Params) : Int32 | Nil
if params.has_key?("udid") && params["udid"] != ""
if params.has_key?("udid") && !params["udid"].blank?
params["udid"].to_i32?
else
get_account_id_from_params(params)
@ -63,7 +63,7 @@ module CrystalGauntlet::Accounts
end
def verify_gjp(account_id : Int32, gjp : String) : Bool
if gjp == ""
if gjp.blank?
return false
end
hash = DATABASE.scalar("select password from accounts where id = ?", account_id).as(String)

View File

@ -95,7 +95,7 @@ module CrystalGauntlet::Songs
if source == "unknown"
return UNKNOWN_SONG_AUTHOR
end
if artist_name == ""
if artist_name.blank?
return UNKNOWN_SONG_AUTHOR
end