MCPcopy Create free account
hub / github.com/vale-cli/vale / ReplaceFileExt

Function ReplaceFileExt

internal/system/file.go:26–36  ·  view source on GitHub ↗

ReplaceExt replaces the extension of `fp` with `ext` if the extension of `fp` is in `formats`. This is used in places where we need to normalize file extensions (e.g., `foo.mdx` -> `foo.md`) in order to respect format associations.

(fp string, formats map[string]string)

Source from the content-addressed store, hash-verified

24// This is used in places where we need to normalize file extensions (e.g.,
25// `foo.mdx` -> `foo.md`) in order to respect format associations.
26func ReplaceFileExt(fp string, formats map[string]string) string {
27 var ext string
28
29 old := filepath.Ext(fp)
30 if normed, found := formats[strings.Trim(old, ".")]; found {
31 ext = "." + normed
32 fp = fp[0:len(fp)-len(old)] + ext
33 }
34
35 return fp
36}

Callers 2

skipMethod · 0.92
NewFileFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…