mirror of
https://github.com/MontFerret/ferret.git
synced 2025-03-21 21:47:43 +02:00
* Added release notes * #509 fixedOCOD typo * Updated values * Updated comments * Changed stdlib docs format * Changed format of array in docs * Use 'any' instead of 'value' in docs * New format for optional params * Updated docs for testing package * Added namespace information
32 lines
681 B
Go
32 lines
681 B
Go
package path
|
|
|
|
import (
|
|
"context"
|
|
"path"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
|
)
|
|
|
|
// IS_ABS reports whether the path is absolute.
|
|
// @param {String} path - The path.
|
|
// @return {Boolean} - True if the path is absolute.
|
|
func IsAbs(_ context.Context, args ...core.Value) (core.Value, error) {
|
|
err := core.ValidateArgs(args, 1, 1)
|
|
|
|
if err != nil {
|
|
return values.False, err
|
|
}
|
|
|
|
err = core.ValidateType(args[0], types.String)
|
|
|
|
if err != nil {
|
|
return values.None, err
|
|
}
|
|
|
|
pathText := args[0].String()
|
|
|
|
return values.NewBoolean(path.IsAbs(pathText)), nil
|
|
}
|