ref: 42ed602580a672e420e1d860384e812f4871ff67
parent: 6a2968fd5c0116d93de0f379ac615e9076821899
author: Anthony Fok <[email protected]>
date: Tue Jun 12 17:27:47 EDT 2018
hugolib: Replace deprecated {Get,}ByPrefix with {Get,}Match
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -415,7 +415,7 @@
require.NotNil(t, bundleFr)
require.Equal(t, "/blog/fr/bundles/b1/", bundleFr.RelPermalink())
require.Equal(t, 1, len(bundleFr.Resources))
- logoFr := bundleFr.Resources.GetByPrefix("logo")
+ logoFr := bundleFr.Resources.GetMatch("logo*")
require.NotNil(t, logoFr)
require.Equal(t, "/blog/fr/bundles/b1/logo.png", logoFr.RelPermalink())
b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")
@@ -424,7 +424,7 @@
require.NotNil(t, bundleEn)
require.Equal(t, "/blog/en/bundles/b1/", bundleEn.RelPermalink())
require.Equal(t, 1, len(bundleEn.Resources))
- logoEn := bundleEn.Resources.GetByPrefix("logo")
+ logoEn := bundleEn.Resources.GetMatch("logo*")
require.NotNil(t, logoEn)
require.Equal(t, "/blog/en/bundles/b1/logo.png", logoEn.RelPermalink())
b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data")
--- a/hugolib/hugo_sites_multihost_test.go
+++ b/hugolib/hugo_sites_multihost_test.go
@@ -96,7 +96,7 @@
require.NotNil(t, bundleEn)
require.Equal(t, "/docs/bundles/b1/", bundleEn.RelPermalink())
require.Equal(t, 1, len(bundleEn.Resources))
- logoEn := bundleEn.Resources.GetByPrefix("logo")
+ logoEn := bundleEn.Resources.GetMatch("logo*")
require.NotNil(t, logoEn)
require.Equal(t, "/docs/bundles/b1/logo.png", logoEn.RelPermalink())
b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data")
@@ -105,7 +105,7 @@
require.NotNil(t, bundleFr)
require.Equal(t, "/bundles/b1/", bundleFr.RelPermalink())
require.Equal(t, 1, len(bundleFr.Resources))
- logoFr := bundleFr.Resources.GetByPrefix("logo")
+ logoFr := bundleFr.Resources.GetMatch("logo*")
require.NotNil(t, logoFr)
require.Equal(t, "/bundles/b1/logo.png", logoFr.RelPermalink())
b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")
--- a/hugolib/page_bundler_test.go
+++ b/hugolib/page_bundler_test.go
@@ -147,9 +147,9 @@
assert.Equal(leafBundle1, firstPage.Parent())
assert.Equal(leafBundle1, secondPage.Parent())
- assert.Equal(firstPage, pageResources.GetByPrefix("1"))
- assert.Equal(secondPage, pageResources.GetByPrefix("2"))
- assert.Nil(pageResources.GetByPrefix("doesnotexist"))
+ assert.Equal(firstPage, pageResources.GetMatch("1*"))
+ assert.Equal(secondPage, pageResources.GetMatch("2*"))
+ assert.Nil(pageResources.GetMatch("doesnotexist*"))
imageResources := leafBundle1.Resources.ByType("image")
assert.Equal(3, len(imageResources))
@@ -265,9 +265,9 @@
// See https://github.com/gohugoio/hugo/issues/4295
// Every resource should have its Name prefixed with its base folder.
- cBundleResources := bundleWithSubPath.Resources.ByPrefix("c/")
+ cBundleResources := bundleWithSubPath.Resources.Match("c/**")
assert.Equal(4, len(cBundleResources))
- bundlePage := bundleWithSubPath.Resources.GetByPrefix("c/page")
+ bundlePage := bundleWithSubPath.Resources.GetMatch("c/page*")
assert.NotNil(bundlePage)
assert.IsType(&Page{}, bundlePage)
@@ -490,7 +490,7 @@
singleLayout := `
Single Title: {{ .Title }}
Content: {{ .Content }}
-{{ $sunset := .Resources.GetByPrefix "my-sunset-1" }}
+{{ $sunset := .Resources.GetMatch "my-sunset-1*" }}
{{ with $sunset }}
Sunset RelPermalink: {{ .RelPermalink }}
{{ $thumb := .Fill "123x123" }}
@@ -509,7 +509,7 @@
myShort := `
MyShort in {{ .Page.Path }}:
-{{ $sunset := .Page.Resources.GetByPrefix "my-sunset-2" }}
+{{ $sunset := .Page.Resources.GetMatch "my-sunset-2*" }}
{{ with $sunset }}
Short Sunset RelPermalink: {{ .RelPermalink }}
{{ $thumb := .Fill "56x56" }}