Create Component Library (#43)
* Move src under playlet-lib * Update configuration * Update script * Update script * Working version * Vs code config WIP * Package lock sync * Lint fix * Fix images * Reuse config files * Kind of a working setup * Lock node version * Rename scripts to tools * Fix build scripts, lib url system * Lint fix * rale * Fix args and web server * Load fallbacks and build script cleanups * Remove unused method * no message * no message * Remove generic message field * Lint fix * no message * Use loading indicator on main app * Add playlet lib version to settings --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
90df81df4b
commit
9d8a3d1cea
156 files changed
+3341
-213
No files matched your search
@@ -0,0 +1,17 @@
|
||||
function GetSha256(input as string) as string
|
||||
buffer = CreateObject("roByteArray")
|
||||
buffer.FromAsciiString(input)
|
||||
|
||||
digest = CreateObject("roEVPDigest")
|
||||
digest.Setup("sha256")
|
||||
return digest.Process(buffer)
|
||||
end function
|
||||
|
||||
function GetSha1(input as string) as string
|
||||
buffer = CreateObject("roByteArray")
|
||||
buffer.FromAsciiString(input)
|
||||
|
||||
digest = CreateObject("roEVPDigest")
|
||||
digest.Setup("sha1")
|
||||
return digest.Process(buffer)
|
||||
end function
|
||||
@@ -0,0 +1,17 @@
|
||||
function IsDebugMode() as boolean
|
||||
appInfo = CreateObject("roAppInfo")
|
||||
bsConst = appInfo.GetValue("bs_const")
|
||||
symbols = bsConst.Tokenize(";")
|
||||
|
||||
for each symbol in symbols
|
||||
keyValuePair = symbol.Tokenize("=")
|
||||
if keyValuePair.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
if UCase(keyValuePair[0]) = "DEBUG"
|
||||
return UCase(keyValuePair[1]) = "TRUE"
|
||||
end if
|
||||
end for
|
||||
|
||||
return false
|
||||
end function
|
||||
@@ -0,0 +1,89 @@
|
||||
function GetLocalIpAddress() as string
|
||||
if m.ipAddress = invalid or m.ipAddress = ""
|
||||
di = CreateObject("roDeviceInfo")
|
||||
ips = di.GetIPAddrs()
|
||||
for each ip in ips
|
||||
m.ipAddress = ips[ip]
|
||||
return m.ipAddress
|
||||
end for
|
||||
end if
|
||||
return m.ipAddress
|
||||
end function
|
||||
|
||||
function GetUserCountryCode() as string
|
||||
if m.countryCode = invalid or m.countryCode = ""
|
||||
m.countryCode = CreateObject("roDeviceInfo").GetUserCountryCode()
|
||||
end if
|
||||
return m.countryCode
|
||||
end function
|
||||
|
||||
function GetAppInfo() as object
|
||||
if m.appInfo = invalid
|
||||
appInfo = CreateObject("roAppInfo")
|
||||
m.appInfo = {
|
||||
id: appInfo.GetID(),
|
||||
version: appInfo.GetVersion(),
|
||||
lib_version: GetLibVersion()
|
||||
}
|
||||
end if
|
||||
return m.appInfo
|
||||
end function
|
||||
|
||||
function GetLibVersion() as string
|
||||
values = GetLibManifestValues()
|
||||
|
||||
Major = values["major_version"].toInt()
|
||||
Minor = values["minor_version"].toInt()
|
||||
Build = values["build_version"].toInt()
|
||||
|
||||
return `${Major}.${Minor}.${Build}`
|
||||
end function
|
||||
|
||||
function GetLibManifestValues() as object
|
||||
libManifest = ReadAsciiFile("libpkg:/manifest")
|
||||
lines = libManifest.Tokenize(UnixNL())
|
||||
values = {}
|
||||
for each line in lines
|
||||
if line.left(1) = "#"
|
||||
continue for
|
||||
end if
|
||||
keyValuePair = line.Tokenize("=")
|
||||
if keyValuePair.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
|
||||
values[keyValuePair[0]] = keyValuePair[1]
|
||||
end for
|
||||
return values
|
||||
end function
|
||||
|
||||
function GetDeviceInfo() as object
|
||||
if m.deviceInfo = invalid
|
||||
devInfo = CreateObject("roDeviceInfo")
|
||||
m.deviceInfo = {
|
||||
model: devInfo.GetModel(),
|
||||
model_display_name: devInfo.GetModelDisplayName(),
|
||||
model_type: devInfo.GetModelType(),
|
||||
model_details: devInfo.GetModelDetails(),
|
||||
os_version: devInfo.GetOSVersion(),
|
||||
display_type: devInfo.GetDisplayType(),
|
||||
display_mode: devInfo.GetDisplayMode(),
|
||||
display_aspect_ratio: devInfo.GetDisplayAspectRatio(),
|
||||
display_size: devInfo.GetDisplaySize(),
|
||||
video_mode: devInfo.GetVideoMode(),
|
||||
ui_resolution: devInfo.GetUIResolution(),
|
||||
graphics_platform: devInfo.GetGraphicsPlatform(),
|
||||
internet_status: devInfo.GetInternetStatus()
|
||||
}
|
||||
end if
|
||||
return m.deviceInfo
|
||||
end function
|
||||
|
||||
function ArrayIndexOf(array as object, value as string) as integer
|
||||
for i = 0 to array.Count() - 1
|
||||
if array[i] = value
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
return -1
|
||||
end function
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace RegistryUtils
|
||||
|
||||
const DEFAULT_SECTION = "Playlet"
|
||||
|
||||
const INVIDIOUS_INSTANCES = "invidious_instances"
|
||||
const INVIDIOUS_TOKEN = "invidious_token"
|
||||
|
||||
function Read(key as string, section = DEFAULT_SECTION as string) as dynamic
|
||||
sec = CreateObject("roRegistrySection", section)
|
||||
if sec.Exists(key)
|
||||
return sec.Read(key)
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function Write(key as string, value as string, section = DEFAULT_SECTION as string)
|
||||
sec = CreateObject("roRegistrySection", section)
|
||||
sec.Write(key, value)
|
||||
sec.Flush()
|
||||
end function
|
||||
|
||||
function Delete(key as string, section = DEFAULT_SECTION as string)
|
||||
sec = CreateObject("roRegistrySection", section)
|
||||
sec.Delete(key)
|
||||
sec.Flush()
|
||||
end function
|
||||
|
||||
function ReadAll() as object
|
||||
result = {}
|
||||
registry = CreateObject("roRegistry")
|
||||
sectionNames = registry.GetSectionList()
|
||||
for each sectionName in sectionNames
|
||||
section = CreateObject("roRegistrySection", sectionName)
|
||||
keys = section.GetKeyList()
|
||||
values = section.ReadMulti(keys)
|
||||
result[sectionName] = values
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,149 @@
|
||||
REM Functions in this file:
|
||||
REM isnonemptystr
|
||||
REM isnullorempty
|
||||
REM strtobool
|
||||
REM itostr
|
||||
REM strTrim
|
||||
REM strTokenize
|
||||
REM
|
||||
|
||||
'******************************************************
|
||||
'isnonemptystr
|
||||
'
|
||||
'Determine if the given object supports the ifString interface
|
||||
'and returns a string of non zero length
|
||||
'******************************************************
|
||||
function isnonemptystr(obj as dynamic) as boolean
|
||||
return ((obj <> invalid) and (GetInterface(obj, "ifString") <> invalid) and (Len(obj) > 0))
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'isnullorempty
|
||||
'
|
||||
'Determine if the given object is invalid or supports
|
||||
'the ifString interface and returns a string of zero length
|
||||
'******************************************************
|
||||
function isnullorempty(obj as dynamic) as boolean
|
||||
return ((obj = invalid) or (GetInterface(obj, "ifString") = invalid) or (Len(obj) = 0))
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'strtobool
|
||||
'
|
||||
'Convert string to boolean safely. Don't crash
|
||||
'Looks for certain string values
|
||||
'******************************************************
|
||||
function strtobool(obj as dynamic) as boolean
|
||||
if obj = invalid
|
||||
return false
|
||||
end if
|
||||
if type(obj) <> "roString" and type(obj) <> "String"
|
||||
return false
|
||||
end if
|
||||
o = strTrim(obj)
|
||||
o = Lcase(o)
|
||||
if o = "true"
|
||||
return true
|
||||
end if
|
||||
if o = "t"
|
||||
return true
|
||||
end if
|
||||
if o = "y"
|
||||
return true
|
||||
end if
|
||||
if o = "1"
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
'******************************************************
|
||||
'booltostr
|
||||
'
|
||||
'Converts a boolean value to a cannonical string value
|
||||
'******************************************************
|
||||
function booltostr(bool as boolean) as string
|
||||
if bool = true
|
||||
return "true"
|
||||
end if
|
||||
return "false"
|
||||
end function
|
||||
|
||||
'******************************************************
|
||||
'itostr
|
||||
'
|
||||
'Convert int to string. This is necessary because
|
||||
'the builtin Stri(x) prepends whitespace
|
||||
'******************************************************
|
||||
function itostr(i as integer) as string
|
||||
str = Stri(i)
|
||||
return strTrim(str)
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Trim a string
|
||||
'******************************************************
|
||||
function strTrim(str as string) as string
|
||||
st = CreateObject("roString")
|
||||
st.SetString(str)
|
||||
return st.Trim()
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Tokenize a string. Return roList of strings
|
||||
'******************************************************
|
||||
function strTokenize(str as string, delim as string) as object
|
||||
st = CreateObject("roString")
|
||||
st.SetString(str)
|
||||
return st.Tokenize(delim)
|
||||
end function
|
||||
|
||||
function UnixNL() as string
|
||||
return chr(10)
|
||||
end function
|
||||
|
||||
function WinNL() as string
|
||||
return chr(13) + chr(10)
|
||||
end function
|
||||
|
||||
function Quote() as string
|
||||
return chr(34)
|
||||
end function
|
||||
|
||||
function StringLastIndexOf(str as string, substr as string) as integer
|
||||
index = str.InStr(substr)
|
||||
while index <> -1
|
||||
newIndex = str.InStr(index + 1, substr)
|
||||
if newIndex = -1
|
||||
return index
|
||||
end if
|
||||
index = newIndex
|
||||
end while
|
||||
return index
|
||||
end function
|
||||
|
||||
function PathJoin(path1 as string, path2 as string) as string
|
||||
if path1.EndsWith("/")
|
||||
path1 = path1.left(path1.len() - 1)
|
||||
end if
|
||||
if path2.StartsWith("/")
|
||||
path2 = path2.Mid(1)
|
||||
end if
|
||||
return path1 + "/" + path2
|
||||
end function
|
||||
|
||||
function ToBase64(input as string) as string
|
||||
buffer = createObject("roByteArray")
|
||||
buffer.FromAsciiString(input)
|
||||
return buffer.ToBase64String()
|
||||
end function
|
||||
|
||||
function FromBase64(input as string) as string
|
||||
buffer = createObject("roByteArray")
|
||||
buffer.FromBase64String(input)
|
||||
return buffer.ToAsciiString()
|
||||
end function
|
||||
@@ -0,0 +1,112 @@
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace TimeUtils
|
||||
' Helper function convert seconds to mm:ss format
|
||||
' getTime(138) returns 2:18
|
||||
function GetFormattedTime(length as integer) as string
|
||||
minutes = (length \ 60).ToStr()
|
||||
seconds = length mod 60
|
||||
if seconds < 10
|
||||
seconds = "0" + seconds.ToStr()
|
||||
else
|
||||
seconds = seconds.ToStr()
|
||||
end if
|
||||
return minutes + ":" + seconds
|
||||
end function
|
||||
|
||||
function GetFormattedTimeLeft(unixTimestamp as integer) as string
|
||||
if unixTimestamp = invalid
|
||||
return "N/A"
|
||||
end if
|
||||
|
||||
currentTime = TimeUtils.Now().AsSeconds()
|
||||
timeLeft = unixTimestamp - currentTime
|
||||
if timeLeft <= 0
|
||||
return "now"
|
||||
end if
|
||||
|
||||
if timeLeft < 60
|
||||
result = `${timeLeft} second`
|
||||
if timeLeft > 1
|
||||
result += "s"
|
||||
end if
|
||||
return result
|
||||
end if
|
||||
|
||||
timeLeft = timeLeft / 60.0
|
||||
if timeLeft < 60
|
||||
timeLeft = Cint(timeLeft)
|
||||
result = `${timeLeft} minute`
|
||||
if timeLeft > 1
|
||||
result += "s"
|
||||
end if
|
||||
return result
|
||||
end if
|
||||
|
||||
timeLeft = timeLeft / 60.0
|
||||
if timeLeft < 24
|
||||
timeLeft = Cint(timeLeft)
|
||||
result = `${timeLeft} hour`
|
||||
if timeLeft > 1
|
||||
result += "s"
|
||||
end if
|
||||
return result
|
||||
else
|
||||
timeLeft = timeLeft / 24.0
|
||||
timeLeft = Cint(timeLeft)
|
||||
result = `${timeLeft} day`
|
||||
if timeLeft > 1
|
||||
result += "s"
|
||||
end if
|
||||
return result
|
||||
end if
|
||||
end function
|
||||
|
||||
function Now() as object
|
||||
this = m.now
|
||||
if this = invalid
|
||||
this = CreateObject("roDateTime")
|
||||
m.now = this
|
||||
end if
|
||||
this.mark()
|
||||
return this
|
||||
end function
|
||||
|
||||
function RFC1123_Date(when as object) as string
|
||||
wd = when.getWeekday().left(3)
|
||||
dom = Stri(when.getDayOfMonth()).trim()
|
||||
mon = Ucase(TimeUtils.MonthStr(when.getMonth()).left(3))
|
||||
yr = Stri(when.getYear()).trim()
|
||||
hr = Stri(when.getHours()).trim()
|
||||
mn = Stri(when.getMinutes()).trim()
|
||||
sc = Stri(when.getSeconds()).trim()
|
||||
date = wd + ", " + dom + " " + mon + " " + yr + " " + hr + ":" + mn + ":" + sc + " GMT"
|
||||
return date
|
||||
end function
|
||||
|
||||
function MonthStr(mNum as integer) as string
|
||||
ma = m.Num2Month
|
||||
if ma = invalid
|
||||
ma = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
|
||||
m.Num2Month = ma
|
||||
end if
|
||||
return validstr(ma[mNum - 1])
|
||||
end function
|
||||
|
||||
function ParseTime(time as string) as integer
|
||||
hours = 0
|
||||
minutes = 0
|
||||
seconds = 0
|
||||
tokens = time.Tokenize(":")
|
||||
if tokens.Count() = 3
|
||||
hours = tokens[0].ToInt()
|
||||
minutes = tokens[1].ToInt()
|
||||
seconds = tokens[2].ToInt()
|
||||
else if tokens.Count() = 2
|
||||
minutes = tokens[0].ToInt()
|
||||
seconds = tokens[1].ToInt()
|
||||
end if
|
||||
return hours * 3600 + minutes * 60 + seconds
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,150 @@
|
||||
REM Functions in this file:
|
||||
REM isxmlelement
|
||||
REM islist
|
||||
REM isint
|
||||
REM isfunc
|
||||
REM isstr
|
||||
REM isbool
|
||||
REM isfloat
|
||||
REM validstr
|
||||
REM validateParam
|
||||
REM
|
||||
|
||||
'******************************************************
|
||||
'isxmlelement
|
||||
'
|
||||
'Determine if the given object supports the ifXMLElement interface
|
||||
'******************************************************
|
||||
function isxmlelement(obj as dynamic) as boolean
|
||||
return obj <> invalid and GetInterface(obj, "ifXMLElement") <> invalid
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'islist
|
||||
'
|
||||
'Determine if the given object supports the ifList interface
|
||||
'******************************************************
|
||||
function islist(obj as dynamic) as boolean
|
||||
return obj <> invalid and GetInterface(obj, "ifArray") <> invalid
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'isint
|
||||
'
|
||||
'Determine if the given object supports the ifInt interface
|
||||
'******************************************************
|
||||
function isint(obj as dynamic) as boolean
|
||||
return obj <> invalid and GetInterface(obj, "ifInt") <> invalid
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'isfunc
|
||||
'
|
||||
'Determine if the given object supports the function interface
|
||||
'******************************************************
|
||||
function isfunc(obj as dynamic) as boolean
|
||||
tf = type(obj)
|
||||
return tf = "Function" or tf = "roFunction"
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'isstr
|
||||
'
|
||||
'Determine if the given object supports the ifString interface
|
||||
'******************************************************
|
||||
function isstr(obj as dynamic) as boolean
|
||||
return obj <> invalid and GetInterface(obj, "ifString") <> invalid
|
||||
end function
|
||||
|
||||
function isAssocArray(obj as dynamic) as boolean
|
||||
return obj <> invalid and GetInterface(obj, "ifAssociativeArray") <> invalid
|
||||
end function
|
||||
|
||||
'******************************************************
|
||||
'isbool
|
||||
'
|
||||
'Determine if the given object supports the ifBoolean interface
|
||||
'******************************************************
|
||||
function isbool(obj as dynamic) as boolean
|
||||
if obj = invalid
|
||||
return false
|
||||
end if
|
||||
if GetInterface(obj, "ifBoolean") = invalid
|
||||
return false
|
||||
end if
|
||||
return true
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'isfloat
|
||||
'
|
||||
'Determine if the given object supports the ifFloat interface
|
||||
'******************************************************
|
||||
function isfloat(obj as dynamic) as boolean
|
||||
if obj = invalid
|
||||
return false
|
||||
end if
|
||||
if GetInterface(obj, "ifFloat") = invalid
|
||||
return false
|
||||
end if
|
||||
return true
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
' validstr
|
||||
'
|
||||
' always return a valid string. if the argument is
|
||||
' invalid or not a string, return an empty string.
|
||||
'******************************************************
|
||||
function validstr(obj as object) as string
|
||||
if obj <> invalid and GetInterface(obj, "ifString") <> invalid
|
||||
return obj
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
' validint
|
||||
'
|
||||
' Always return a valid integer. If the argument is
|
||||
' invalid or not an integer, return zero.
|
||||
'******************************************************
|
||||
function validint(obj as dynamic) as integer
|
||||
if obj <> invalid and GetInterface(obj, "ifInt") <> invalid
|
||||
return obj
|
||||
else
|
||||
return 0
|
||||
end if
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Validate parameter is the correct type
|
||||
'******************************************************
|
||||
function validateParam(param as object, paramType as string, functionName as string, allowInvalid = false as boolean) as boolean
|
||||
if paramType = "roString" or paramType = "String"
|
||||
if type(param) = "roString" or type(param) = "String"
|
||||
return true
|
||||
end if
|
||||
else if type(param) = paramType
|
||||
return true
|
||||
end if
|
||||
|
||||
if allowInvalid = true
|
||||
if type(param) = invalid
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
print "invalid parameter of type "; type(param); " for "; paramType; " in function "; functionName
|
||||
return false
|
||||
end function
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace WebUtils
|
||||
function UrlQueryComponents(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]
|
||||
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)
|
||||
value = oldValue
|
||||
end if
|
||||
|
||||
query[key] = value
|
||||
end for
|
||||
return query
|
||||
end function
|
||||
|
||||
function MimeType(uri = "" as string) as string
|
||||
map = m.MimeTypes
|
||||
if map = invalid
|
||||
map = {
|
||||
' Default mimetype mappings
|
||||
ogg: "application/ogg",
|
||||
pdf: "application/pdf",
|
||||
xsl: "application/xml",
|
||||
xml: "application/xml",
|
||||
dtd: "application/xml-dtd",
|
||||
xslt: "application/xslt+xml",
|
||||
zip: "application/zip",
|
||||
mp2: "audio/mpeg",
|
||||
mp3: "audio/mpeg",
|
||||
mpga: "audio/mpeg",
|
||||
gif: "image/gif",
|
||||
jpeg: "image/jpeg",
|
||||
jpe: "image/jpeg",
|
||||
jpg: "image/jpeg",
|
||||
png: "image/png",
|
||||
svg: "image/svg+xml",
|
||||
css: "text/css",
|
||||
html: "text/html",
|
||||
js: "text/javascript",
|
||||
txt: "text/plain",
|
||||
asc: "text/plain",
|
||||
brs: "text/plain",
|
||||
bs: "text/plain",
|
||||
map: "text/plain",
|
||||
mpeg: "video/mpeg",
|
||||
mpe: "video/mpeg",
|
||||
mpg: "video/mpeg",
|
||||
qt: "video/quicktime",
|
||||
mov: "video/quicktime",
|
||||
avi: "video/x-msvideo",
|
||||
default: "application/octet-stream"
|
||||
}
|
||||
m.MimeTypes = map
|
||||
end if
|
||||
ext = WebUtils.GetExtension(uri)
|
||||
if map.doesexist(ext)
|
||||
return map[ext]
|
||||
else
|
||||
return map.default
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetExtension(fn as string) as string
|
||||
l = fn.tokenize(".")
|
||||
if l.count() > 0
|
||||
return l.GetTail()
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end function
|
||||
|
||||
function HttpTitle(code = 0 as integer) as string
|
||||
hcm = m.HttpTitles
|
||||
if hcm = invalid
|
||||
hcm = { n101: "Switching Protocols" }
|
||||
hcm.append({ n200: "OK", n206: "Partial Content" })
|
||||
hcm.append({ n301: "Moved Permanently", n304: "Not Modified" })
|
||||
hcm.append({ n400: "Bad Request", n401: "Unauthorized", n403: "Forbidden", n404: "Not Found", n413: "Request Entity Too Large" })
|
||||
hcm.append({ n500: "Internal Server Error", n501: "Not Implemented" })
|
||||
m.HttpTitles = hcm
|
||||
end if
|
||||
return validstr(hcm["n" + Stri(code).trim()])
|
||||
end function
|
||||
|
||||
function EscapeUrlForXml(url as string) as string
|
||||
urlEscapeChars = {}
|
||||
urlEscapeChars["&"] = "&"
|
||||
urlEscapeChars["'"] = "'"
|
||||
urlEscapeChars[`"`] = """
|
||||
urlEscapeChars["<"] = "<"
|
||||
urlEscapeChars[">"] = ">"
|
||||
|
||||
for each escapeChar in urlEscapeChars
|
||||
url = url.Replace(escapeChar, urlEscapeChars[escapeChar])
|
||||
end for
|
||||
return url
|
||||
end function
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user