mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-16 12:12:14 +00:00
Fix off-by-one in tootctl media
commands (#30306)
This commit is contained in:
parent
67b2e62331
commit
8cf78825a2
|
@ -134,7 +134,7 @@ module Mastodon::CLI
|
||||||
|
|
||||||
model_name = path_segments.first.classify
|
model_name = path_segments.first.classify
|
||||||
attachment_name = path_segments[1].singularize
|
attachment_name = path_segments[1].singularize
|
||||||
record_id = path_segments[2..-2].join.to_i
|
record_id = path_segments[2...-2].join.to_i
|
||||||
file_name = path_segments.last
|
file_name = path_segments.last
|
||||||
record = record_map.dig(model_name, record_id)
|
record = record_map.dig(model_name, record_id)
|
||||||
attachment = record&.public_send(attachment_name)
|
attachment = record&.public_send(attachment_name)
|
||||||
|
@ -180,7 +180,7 @@ module Mastodon::CLI
|
||||||
end
|
end
|
||||||
|
|
||||||
model_name = path_segments.first.classify
|
model_name = path_segments.first.classify
|
||||||
record_id = path_segments[2..-2].join.to_i
|
record_id = path_segments[2...-2].join.to_i
|
||||||
attachment_name = path_segments[1].singularize
|
attachment_name = path_segments[1].singularize
|
||||||
file_name = path_segments.last
|
file_name = path_segments.last
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ module Mastodon::CLI
|
||||||
end
|
end
|
||||||
|
|
||||||
model_name = path_segments.first.classify
|
model_name = path_segments.first.classify
|
||||||
record_id = path_segments[2..-2].join.to_i
|
record_id = path_segments[2...-2].join.to_i
|
||||||
|
|
||||||
unless PRELOAD_MODEL_WHITELIST.include?(model_name)
|
unless PRELOAD_MODEL_WHITELIST.include?(model_name)
|
||||||
say("Cannot find corresponding model: #{model_name}", :red)
|
say("Cannot find corresponding model: #{model_name}", :red)
|
||||||
|
@ -361,7 +361,7 @@ module Mastodon::CLI
|
||||||
next unless VALID_PATH_SEGMENTS_SIZE.include?(segments.size)
|
next unless VALID_PATH_SEGMENTS_SIZE.include?(segments.size)
|
||||||
|
|
||||||
model_name = segments.first.classify
|
model_name = segments.first.classify
|
||||||
record_id = segments[2..-2].join.to_i
|
record_id = segments[2...-2].join.to_i
|
||||||
|
|
||||||
next unless PRELOAD_MODEL_WHITELIST.include?(model_name)
|
next unless PRELOAD_MODEL_WHITELIST.include?(model_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue