(runtime *common.RuntimeContext, pathValue string, label string)
| 386 | } |
| 387 | |
| 388 | func readHTML5BlockPath(runtime *common.RuntimeContext, pathValue string, label string) (string, error) { |
| 389 | pathRaw := strings.TrimSpace(pathValue) |
| 390 | if !strings.HasPrefix(pathRaw, "@") { |
| 391 | return "", common.ValidationErrorf("%s %q must start with @, for example @widget.html", label, pathValue).WithParam("path") |
| 392 | } |
| 393 | relPath := strings.TrimSpace(strings.TrimPrefix(pathRaw, "@")) |
| 394 | if relPath == "" { |
| 395 | return "", common.ValidationErrorf("%s cannot be empty after @", label).WithParam("path") |
| 396 | } |
| 397 | clean := filepath.Clean(relPath) |
| 398 | if filepath.IsAbs(clean) || clean == "." || clean == ".." || strings.HasPrefix(clean, ".."+string(filepath.Separator)) { |
| 399 | return "", common.ValidationErrorf("%s %q must be a relative path within the current working directory", label, pathValue).WithParam("path") |
| 400 | } |
| 401 | if strings.ToLower(filepath.Ext(clean)) != ".html" { |
| 402 | return "", common.ValidationErrorf("%s %q must point to a .html file", label, pathValue).WithParam("path") |
| 403 | } |
| 404 | data, err := cmdutil.ReadInputFile(runtime.FileIO(), clean) |
| 405 | if err != nil { |
| 406 | return "", common.ValidationErrorf("%s %q cannot be read from the current working directory; check that the file exists relative to where lark-cli is running: %v", label, clean, err).WithParam("path").WithCause(err) |
| 407 | } |
| 408 | return string(data), nil |
| 409 | } |
| 410 | |
| 411 | func hasProcessableHTML5Block(format string, content string) bool { |
| 412 | if !strings.Contains(content, "<html5-block") { |
no test coverage detected