Fix: correctly match http/https URLs in image upload file (#24180)
This commit is contained in:
parent
7c7618c083
commit
6b5c2bea4d
6 changed files with 34 additions and 26 deletions
|
|
@ -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"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue