aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorbep <[email protected]>2015-05-25 13:10:26 +0200
committerbep <[email protected]>2015-05-25 13:10:40 +0200
commitbeee679dfbdeadc61af1705b860283875a9fd696 (patch)
tree84f71f90df20b7b92f5293fe1191e377810686bc /helpers
parentbe79c35bda0154e36d3bc60e8f7bb00d17952e05 (diff)
downloadhugo-beee679dfbdeadc61af1705b860283875a9fd696.tar.gz
hugo-beee679dfbdeadc61af1705b860283875a9fd696.zip
Unexport filepath/path bridge types
They are of no use outside the helpers package. See #1160
Diffstat (limited to 'helpers')
-rw-r--r--helpers/path.go30
-rw-r--r--helpers/path_test.go2
-rw-r--r--helpers/url.go20
3 files changed, 26 insertions, 26 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 4924fa581..71ffee980 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -27,8 +27,8 @@ import (
"unicode"
)
-// FilepathPathBridge is a bridge for common functionality in filepath vs path
-type FilepathPathBridge interface {
+// filepathPathBridge is a bridge for common functionality in filepath vs path
+type filepathPathBridge interface {
Base(in string) string
Clean(in string) string
Dir(in string) string
@@ -37,34 +37,34 @@ type FilepathPathBridge interface {
Separator() string
}
-type FilepathBridge struct {
+type filepathBridge struct {
}
-func (FilepathBridge) Base(in string) string {
+func (filepathBridge) Base(in string) string {
return filepath.Base(in)
}
-func (FilepathBridge) Clean(in string) string {
+func (filepathBridge) Clean(in string) string {
return filepath.Clean(in)
}
-func (FilepathBridge) Dir(in string) string {
+func (filepathBridge) Dir(in string) string {
return filepath.Dir(in)
}
-func (FilepathBridge) Ext(in string) string {
+func (filepathBridge) Ext(in string) string {
return filepath.Ext(in)
}
-func (FilepathBridge) Join(elem ...string) string {
+func (filepathBridge) Join(elem ...string) string {
return filepath.Join(elem...)
}
-func (FilepathBridge) Separator() string {
+func (filepathBridge) Separator() string {
return FilePathSeparator
}
-var filepathBridge FilepathBridge
+var fpb filepathBridge
var sanitizeRegexp = regexp.MustCompile("[^a-zA-Z0-9./_-]")
// MakePath takes a string with any characters and replace it
@@ -103,7 +103,7 @@ func UnicodeSanitize(s string) string {
// 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, filepathBridge)
+ f, _ := FileAndExt(path, fpb)
return f + "." + newExt
}
@@ -270,7 +270,7 @@ func GetDottedRelativePath(inPath string) string {
// Filename takes a path, strips out the extension,
// and returns the name of the file.
func Filename(in string) (name string) {
- name, _ = FileAndExt(in, filepathBridge)
+ name, _ = FileAndExt(in, fpb)
return
}
@@ -290,7 +290,7 @@ func Filename(in string) (name string) {
// 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)
@@ -396,10 +396,10 @@ func PathPrep(ugly bool, in string) string {
// /section/name/ becomes /section/name/index.html
// /section/name/index.html becomes /section/name/index.html
func PrettifyPath(in string) string {
- return PrettiyPath(in, filepathBridge)
+ return PrettiyPath(in, fpb)
}
-func PrettiyPath(in string, b FilepathPathBridge) string {
+func PrettiyPath(in string, b filepathPathBridge) string {
if filepath.Ext(in) == "" {
// /section/name/ -> /section/name/index.html
if len(in) < 2 {
diff --git a/helpers/path_test.go b/helpers/path_test.go
index 356fb4c91..c9b4beac1 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -535,7 +535,7 @@ func TestFileAndExt(t *testing.T) {
}
for i, d := range data {
- file, ext := FileAndExt(filepath.FromSlash(d.input), filepathBridge)
+ 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)
}
diff --git a/helpers/url.go b/helpers/url.go
index ce36bc184..76cc08813 100644
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -23,34 +23,34 @@ import (
"github.com/spf13/viper"
)
-type PathBridge struct {
+type pathBridge struct {
}
-func (PathBridge) Base(in string) string {
+func (pathBridge) Base(in string) string {
return path.Base(in)
}
-func (PathBridge) Clean(in string) string {
+func (pathBridge) Clean(in string) string {
return path.Clean(in)
}
-func (PathBridge) Dir(in string) string {
+func (pathBridge) Dir(in string) string {
return path.Dir(in)
}
-func (PathBridge) Ext(in string) string {
+func (pathBridge) Ext(in string) string {
return path.Ext(in)
}
-func (PathBridge) Join(elem ...string) string {
+func (pathBridge) Join(elem ...string) string {
return path.Join(elem...)
}
-func (PathBridge) Separator() string {
+func (pathBridge) Separator() string {
return "/"
}
-var pathBridge PathBridge
+var pb pathBridge
func sanitizeURLWithFlags(in string, f purell.NormalizationFlags) string {
s, err := purell.NormalizeURLString(in, f)
@@ -244,7 +244,7 @@ func PrettifyURL(in string) string {
// /section/name/ becomes /section/name/index.html
// /section/name/index.html becomes /section/name/index.html
func PrettifyURLPath(in string) string {
- return PrettiyPath(in, pathBridge)
+ return PrettiyPath(in, pb)
}
// Uglify does the opposite of PrettifyURLPath().
@@ -260,7 +260,7 @@ func Uglify(in string) string {
return path.Clean(in) + ".html"
}
- name, ext := FileAndExt(in, pathBridge)
+ name, ext := FileAndExt(in, pb)
if name == "index" {
// /section/name/index.html -> /section/name.html
d := path.Dir(in)