Warn about old API url (#174)

This commit is contained in:
Alex Ling 2021-03-10 05:47:25 +00:00
parent 3a82effa40
commit eec6ec60bf

View File

@ -93,14 +93,23 @@ class Config
raise "Login is disabled, but default username is not set. " \ raise "Login is disabled, but default username is not set. " \
"Please set a default username" "Please set a default username"
end end
# `Logger.default` is not available yet
Log.setup :debug
unless mangadex["api_url"] =~ /\/v2/ unless mangadex["api_url"] =~ /\/v2/
# `Logger.default` is not available yet
Log.setup :debug
Log.warn { "It looks like you are using the deprecated MangaDex API " \ Log.warn { "It looks like you are using the deprecated MangaDex API " \
"v1 in your config file. Please update it to " \ "v1 in your config file. Please update it to " \
"https://api.mangadex.org/v2 to suppress this warning." } "https://api.mangadex.org/v2 to suppress this warning." }
mangadex["api_url"] = "https://api.mangadex.org/v2" mangadex["api_url"] = "https://api.mangadex.org/v2"
end end
if mangadex["api_url"] =~ /\/api\/v2/
Log.warn { "It looks like you are using the outdated MangaDex API " \
"url (mangadex.org/api/v2) in your config file. Please " \
"update it to https://api.mangadex.org/v2 to suppress this " \
"warning." }
mangadex["api_url"] = "https://api.mangadex.org/v2"
end
mangadex["api_url"] = mangadex["api_url"].to_s.rstrip "/" mangadex["api_url"] = mangadex["api_url"].to_s.rstrip "/"
mangadex["base_url"] = mangadex["base_url"].to_s.rstrip "/" mangadex["base_url"] = mangadex["base_url"].to_s.rstrip "/"
end end