From d1adbab050a2de21088dbdd07215548e8313db3a Mon Sep 17 00:00:00 2001 From: Pierce Date: Sun, 27 Oct 2024 23:33:53 -0400 Subject: [PATCH] update url.lua to do urls with path and without path seperately --- lua/cfc_http_restrictions/shared/url.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/cfc_http_restrictions/shared/url.lua b/lua/cfc_http_restrictions/shared/url.lua index 48cc50a..2b14786 100644 --- a/lua/cfc_http_restrictions/shared/url.lua +++ b/lua/cfc_http_restrictions/shared/url.lua @@ -6,7 +6,13 @@ CFCHTTP.URLPattern = "(%a+)://([^:/ \t]+):?(%d*)/?.*" -CFCHTTP.URLPatternNoGroups = "%a+://[^:/'\"%) \t\"]+:?%d*/?[^\n\" \\]*" + +-- Deprecated +CFCHTTP.URLPatternNoGroups = "%a+://[^:/ \t\"]+:?%d*/?[^\n\" \\]*" + +CFCHTTP.URLPatternNoGroupsNoPath = "%a+://[^:/ \t\"]+:?%d*" +CFCHTTP.URLPatternNoGroupsHasPath = "%a+://[^:/ \t\"]+:?%d*/[^\n\" \\]*" + ---@param url string ---@return URLData @@ -55,7 +61,8 @@ end ---@param f fun( url:string ):string ---@return string function CFCHTTP.ReplaceURLs( text, f ) - local html = string.gsub( text, CFCHTTP.URLPatternNoGroups, f ) + local html = string.gsub( text, CFCHTTP.URLPatternNoGroupsNoPath, f ) + html = string.gsub( html, CFCHTTP.URLPatternNoGroupsHasPath, f ) return html end