From 65ab7f1eb5fe144ef525a4b2bc2680ed725fafde Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 4 Nov 2021 03:47:21 -0500 Subject: [PATCH] API: fix regression in `expires_in` URL parameter. Fix `https://danbooru.donmai.us/artists.json?expires_in=300` failing with an `'300' is not a valid duration` error. This call pattern is used by the Translate Pixiv Tags userscript. Caused by a5ed8c72, which changed the `age:N` metatag to require time units, but this inadvertently changed the `expires_in` parameter to require them too. Using `expires_in` without time units is deprecated and will be removed in the future. --- app/logical/application_responder.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/logical/application_responder.rb b/app/logical/application_responder.rb index 3ca29de86..df8290306 100644 --- a/app/logical/application_responder.rb +++ b/app/logical/application_responder.rb @@ -10,7 +10,9 @@ class ApplicationResponder < ActionController::Responder if get? if params["expires_in"] - controller.expires_in(DurationParser.parse(params["expires_in"])) + expires_in = params["expires_in"] + expires_in += "seconds" if expires_in =~ /\d+\z/ + controller.expires_in(DurationParser.parse(expires_in)) elsif request.params["expiry"] controller.expires_in(params["expiry"].to_i.days) end