Skip to content

Commit

Permalink
Add dropbox url converter func (#1619)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Feb 14, 2024
1 parent a1acfca commit ffe60f7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lua/starfall/libs_sh/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,15 @@ end
-- @param string url The url to convert
-- @return string The converted url
function http_library.urlGoogleDriveToRaw(url)
local id = string.match(url, "https://drive%.google%.com/file/d/([^/]+)/view")
if not id then SF.Throw("Failed to parse google drive link!", 2) end
return "https://drive.google.com/uc?export=download&id="..id
local id = string.match(url, "https://drive%.google%.com/file/d/([^/]+)/view") or SF.Throw("Failed to parse google drive link!", 2)
return "https://drive.google.com/uc?export=download&id="..id
end

--- Converts a regular dropbox url to a raw one
-- @param string url The url to convert
-- @return string The converted url
function http_library.urlDropboxToRaw(url)
return string.gsub(url, "www%.dropbox%.com", "dl%.dropboxusercontent%.com")
end

end

0 comments on commit ffe60f7

Please sign in to comment.