mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
27 lines
760 B
Go
27 lines
760 B
Go
|
package strings
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"html"
|
||
|
|
||
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||
|
)
|
||
|
|
||
|
// UnescapeHTML unescapes entities like "<" to become "<". It unescapes a
|
||
|
// larger range of entities than EscapeString escapes. For example, "á"
|
||
|
// unescapes to "á", as does "á" and "á".
|
||
|
// UnescapeString(EscapeString(s)) == s always holds, but the converse isn't
|
||
|
// always true.
|
||
|
// @param (String) - Uri to escape.
|
||
|
// @returns String - Escaped string.
|
||
|
func UnescapeHTML(_ context.Context, args ...core.Value) (core.Value, error) {
|
||
|
err := core.ValidateArgs(args, 1, 1)
|
||
|
|
||
|
if err != nil {
|
||
|
return values.None, err
|
||
|
}
|
||
|
|
||
|
return values.NewString(html.UnescapeString(args[0].String())), nil
|
||
|
}
|