From 1889973af148e48ce0223daedad976baf188af32 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 3 Jan 2021 20:06:07 +1100 Subject: [PATCH] Dedupe assetbundle --- v2/internal/html/assetbundle.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/v2/internal/html/assetbundle.go b/v2/internal/html/assetbundle.go index ea5b69852..0feffc281 100644 --- a/v2/internal/html/assetbundle.go +++ b/v2/internal/html/assetbundle.go @@ -61,6 +61,8 @@ func (a *AssetBundle) processHTML(htmldata string) error { buf := bytes.NewBufferString(htmldata) tokenizer := html.NewTokenizer(buf) + paths := slicer.String() + for { //get the next token type tokenType := tokenizer.Next() @@ -109,7 +111,12 @@ func (a *AssetBundle) processHTML(htmldata string) error { if err != nil { return err } - a.assets = append(a.assets, asset) + + // Ensure we don't include duplicates + if !paths.Contains(asset.Path) { + a.assets = append(a.assets, asset) + paths.Add(asset.Path) + } } if "script" == token.Data {