Refactor query params
This commit is contained in:
1 parent
0ddc9a48aa
commit
0acb7031d3
6 files changed
+162
-128
No files matched your search
@@ -6,6 +6,7 @@ import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/LoadingScreen.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/UrlUtils.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
@@ -222,7 +223,7 @@ function Search(text as string)
|
||||
else if IsArray(value) and value.Count() > 0
|
||||
feedSource.queryParams[filter] = {
|
||||
value: value,
|
||||
arrayType: HttpClient.QueryParamArrayType.CommaSeparated
|
||||
arrayType: UrlUtils.QueryParamArrayType.CommaSeparated
|
||||
}
|
||||
end if
|
||||
end for
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
|
||||
import "pkg:/source/services/XmlObject.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/UrlUtils.bs"
|
||||
|
||||
class DashManifest
|
||||
|
||||
@@ -349,7 +350,7 @@ class DashManifest
|
||||
|
||||
function ParseAudioLanguage(url as string) as object
|
||||
result = { lang: "", acont: "" }
|
||||
queryParams = m.utils.ParseUrlQueryComponents(url)
|
||||
queryParams = UrlUtils.ParseQueryComponents(url)
|
||||
if StringUtils.IsNullOrEmpty(queryParams["xtags"])
|
||||
return result
|
||||
end if
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import "HttpRequestState.bs"
|
||||
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
import "pkg:/source/utils/UrlUtils.bs"
|
||||
|
||||
namespace Http
|
||||
|
||||
@@ -202,7 +203,7 @@ namespace Http
|
||||
split = m.route.Instr("?")
|
||||
if split <> -1
|
||||
m.route = m.route.Left(split)
|
||||
m.query = utils.ParseUrlQueryComponents(m.uri)
|
||||
m.query = UrlUtils.ParseQueryComponents(m.uri)
|
||||
else
|
||||
m.query = {}
|
||||
end if
|
||||
|
||||
@@ -3,39 +3,6 @@ import "pkg:/source/utils/Types.bs"
|
||||
namespace Http
|
||||
|
||||
class Utils
|
||||
|
||||
function ParseUrlQueryComponents(url as string) as object
|
||||
query = {}
|
||||
index = Instr(0, url, "?")
|
||||
url = Mid(url, index + 1)
|
||||
components = url.split("&")
|
||||
for each component in components
|
||||
key = component
|
||||
value = ""
|
||||
hasValue = false
|
||||
if Instr(0, component, "=")
|
||||
keyValue = component.split("=")
|
||||
key = keyValue[0]
|
||||
value = keyValue[1].DecodeUriComponent()
|
||||
hasValue = true
|
||||
end if
|
||||
|
||||
if query.DoesExist(key) and hasValue
|
||||
oldValue = query[key]
|
||||
if GetInterface(oldValue, "ifArray") = invalid
|
||||
oldValue = [oldValue]
|
||||
end if
|
||||
oldValue.push(value.DecodeUriComponent())
|
||||
value = oldValue
|
||||
end if
|
||||
|
||||
if key <> ""
|
||||
query[key] = value
|
||||
end if
|
||||
end for
|
||||
return query
|
||||
end function
|
||||
|
||||
function MimeType(uri = "" as string) as string
|
||||
map = m.MimeTypes
|
||||
if map = invalid
|
||||
@@ -50,22 +17,22 @@ namespace Http
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetExtension(fn as string) as string
|
||||
l = fn.tokenize(".")
|
||||
if l.count() > 0
|
||||
return l.GetTail()
|
||||
function GetExtension(filename as string) as string
|
||||
parts = filename.tokenize(".")
|
||||
if parts.count() > 0
|
||||
return parts.GetTail()
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end function
|
||||
|
||||
function HttpTitle(code = 0 as integer) as string
|
||||
hcm = m.HttpTitles
|
||||
if hcm = invalid
|
||||
hcm = ParseJson(ReadAsciiFile("libpkg:/config/http-codes.json5"))
|
||||
m.HttpTitles = hcm
|
||||
map = m.httpCodesMap
|
||||
if map = invalid
|
||||
map = ParseJson(ReadAsciiFile("libpkg:/config/http-codes.json5"))
|
||||
m.httpCodesMap = map
|
||||
end if
|
||||
return ValidString(hcm[`${code}`])
|
||||
return ValidString(map[`${code}`])
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
Reference in new issue
Block a user