Fix: correctly match http/https URLs in image upload file (#24180)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from core.tools.utils.web_reader_tool import get_image_upload_file_ids
|
||||
|
||||
|
||||
def test_get_image_upload_file_ids():
|
||||
# should extract id from https + file-preview
|
||||
content = ""
|
||||
assert get_image_upload_file_ids(content) == ["abc123"]
|
||||
|
||||
# should extract id from http + image-preview
|
||||
content = ""
|
||||
assert get_image_upload_file_ids(content) == ["xyz789"]
|
||||
|
||||
# should not match invalid scheme 'htt://'
|
||||
content = ""
|
||||
assert get_image_upload_file_ids(content) == []
|
||||
|
||||
# should extract multiple ids in order
|
||||
content = """
|
||||
some text
|
||||

|
||||
middle
|
||||

|
||||
end
|
||||
"""
|
||||
assert get_image_upload_file_ids(content) == ["id1", "id2"]
|
||||
Reference in New Issue
Block a user