Source File
trustedresourceurl.go
Belonging Package
github.com/google/safehtml
package safehtml
import (
)
func ( TrustedResourceURL, map[string]string) TrustedResourceURL {
:= .str
var string
= [:]
= [:]
}
:= "?"
if == len()-1 {
= ""
} else {
= "&"
}
}
for , := range {
if == "" || == "" {
continue
}
+= + safehtmlutil.QueryEscapeURL() + "=" + safehtmlutil.QueryEscapeURL()
= "&"
}
return TrustedResourceURL{ + }
}
func ( stringConstant) TrustedResourceURL {
return TrustedResourceURL{string()}
}
func ( stringConstant, map[string]string) (TrustedResourceURL, error) {
return trustedResourceURLFormat(string(), )
}
func ( flag.Value, map[string]string) (TrustedResourceURL, error) {
return trustedResourceURLFormat(fmt.Sprint(.String()), )
}
func ( string, map[string]string) (TrustedResourceURL, error) {
if !safehtmlutil.IsSafeTrustedResourceURLPrefix() {
return TrustedResourceURL{}, fmt.Errorf("%q is a disallowed TrustedResourceURL format string", )
}
var error
:= trustedResourceURLFormatMarkerPattern.ReplaceAllStringFunc(, func( string) string {
:= [len("%{") : len()-len("}")]
, := []
if ! {
return safehtmlutil.QueryEscapeURL()
})
return TrustedResourceURL{},
}
var trustedResourceURLFormatMarkerPattern = regexp.MustCompile(`%{[[:word:]]+}`)
func ( flag.Value) TrustedResourceURL {
return TrustedResourceURL{fmt.Sprint(.String())}
}
func ( TrustedResourceURL) () string {
return .str
}
func ( TrustedResourceURL, string) (TrustedResourceURL, error) {
if !safehtmlutil.IsSafeTrustedResourceURLPrefix(.str) {
return TrustedResourceURL{}, fmt.Errorf("cannot append to TrustedResourceURL %q because it has an unsafe prefix", )
}
return TrustedResourceURL{.str + safehtmlutil.QueryEscapeURL()}, nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |