From eec6ec60bff4e261adcf54c8635688bf4db9d22f Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Wed, 10 Mar 2021 05:47:25 +0000 Subject: [PATCH] Warn about old API url (#174) --- src/config.cr | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config.cr b/src/config.cr index b9885a2..a05c3a7 100644 --- a/src/config.cr +++ b/src/config.cr @@ -93,14 +93,23 @@ class Config raise "Login is disabled, but default username is not set. " \ "Please set a default username" end + + # `Logger.default` is not available yet + Log.setup :debug 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 " \ "v1 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 + 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["base_url"] = mangadex["base_url"].to_s.rstrip "/" end