// ReplaceExtension takes a path and an extension, strips the old extension
// and returns the path with the new extension.
func ReplaceExtension(path string, newExt string) string {
- f, _ := FileAndExt(path, fpb)
+ f, _ := fileAndExt(path, fpb)
return f + "." + newExt
}
// Filename takes a path, strips out the extension,
// and returns the name of the file.
func Filename(in string) (name string) {
- name, _ = FileAndExt(in, fpb)
+ name, _ = fileAndExt(in, fpb)
return
}
// If the path, in, represents a filename with an extension,
// then name will be the filename minus any extension - including the dot
// and ext will contain the extension - minus the dot.
-func FileAndExt(in string, b filepathPathBridge) (name string, ext string) {
+func fileAndExt(in string, b filepathPathBridge) (name string, ext string) {
ext = b.Ext(in)
base := b.Base(in)
}
return b.Join(b.Clean(in), "index.html")
}
- name, ext := FileAndExt(in, b)
+ name, ext := fileAndExt(in, b)
if name == "index" {
// /section/name/index.html -> /section/name/index.html
return b.Clean(in)
}
for i, d := range data {
- file, ext := FileAndExt(filepath.FromSlash(d.input), fpb)
+ file, ext := fileAndExt(filepath.FromSlash(d.input), fpb)
if d.expectedFile != file {
t.Errorf("Test %d failed. Expected filename %q got %q.", i, d.expectedFile, file)
}
return path.Clean(in) + ".html"
}
- name, ext := FileAndExt(in, pb)
+ name, ext := fileAndExt(in, pb)
if name == "index" {
// /section/name/index.html -> /section/name.html
d := path.Dir(in)