From ffe60f7c5c4931131e6ed4b8aaef74d37ba0cb42 Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Wed, 14 Feb 2024 05:12:40 -0500 Subject: [PATCH] Add dropbox url converter func (#1619) --- lua/starfall/libs_sh/http.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/starfall/libs_sh/http.lua b/lua/starfall/libs_sh/http.lua index fc01072ac..2a70e1407 100644 --- a/lua/starfall/libs_sh/http.lua +++ b/lua/starfall/libs_sh/http.lua @@ -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