File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 6767
6868function PIXEL .GetImage (url , callback , matSettings )
6969 local protocol = url :match (" ^([%a]+://)" )
70- local urlWithoutProtocol = url
71- if not protocol then
72- protocol = " http:// "
73- else
74- urlWithoutProtocol = string.gsub ( url , protocol , " " )
70+
71+ local hasTrailingSlash = url : sub ( - 1 ) == " / "
72+ local urlWithoutTrailingSlash = url
73+ if hasTrailingSlash then
74+ urlWithoutTrailingSlash = url : sub ( 1 , - 2 )
7575 end
7676
77- local fileNameStart = url :find (" [^/]+$" )
77+ local fileNameStart = urlWithoutTrailingSlash :find (" [^/]+$" )
7878 if not fileNameStart then
7979 return
8080 end
8181
82- local urlWithoutFileName = url :sub (protocol :len () + 1 , fileNameStart - 1 )
82+ local urlWithoutProtocol = url
83+ if not protocol then
84+ protocol = " http://"
85+ else
86+ urlWithoutProtocol = string.gsub (urlWithoutTrailingSlash , protocol , " " )
87+ end
88+
89+ local urlWithoutFileName = urlWithoutTrailingSlash :sub (protocol :len () + 1 , fileNameStart - 1 )
8390
8491 local dirPath = PIXEL .DownloadPath .. urlWithoutFileName
8592 local filePath = PIXEL .DownloadPath .. urlWithoutProtocol
You can’t perform that action at this time.
0 commit comments