fix tootctl media lookup fails on local media URLs (#39615)
This commit is contained in:
parent
7198db59bf
commit
27c66a997f
@ -273,11 +273,12 @@ module Mastodon::CLI
|
|||||||
def lookup(url)
|
def lookup(url)
|
||||||
path = Addressable::URI.parse(url).path
|
path = Addressable::URI.parse(url).path
|
||||||
|
|
||||||
path_segments = path.split('/')[2..]
|
path_segments = path.split('/')
|
||||||
path_segments.delete('cache')
|
segment_count = VALID_PATH_SEGMENTS_SIZE.find { |n| n <= path_segments.length && PRELOADED_MODELS.include?(path_segments[-n].classify) }
|
||||||
|
|
||||||
fail_with_message 'Not a media URL' unless VALID_PATH_SEGMENTS_SIZE.include?(path_segments.size)
|
fail_with_message 'Not a media URL' unless segment_count
|
||||||
|
|
||||||
|
path_segments = path_segments[-segment_count..]
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user