From b5c02821fa9d98e8fda71142d31dfe350ab1c68d Mon Sep 17 00:00:00 2001 From: Fernando Elizalde Date: Thu, 16 Jun 2022 10:40:57 -0500 Subject: [PATCH] remove hue from js links --- linker.go | 4 ++-- linker_test.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/linker.go b/linker.go index 0c91eaf..aa658b3 100644 --- a/linker.go +++ b/linker.go @@ -14,7 +14,7 @@ type Linker struct { func new_linker(paths string) Linker { quoted := `([='"])(` + paths + ")" - hue_base := `window.HUE_BASE_URL\s*[+]\s*'/hue'\s*[+]` + hue_base := `window.HUE_BASE_URL\s*[+]\s*'/hue'` linker := Linker{ quoted_reg: regexp.MustCompile(quoted), @@ -28,7 +28,7 @@ func (l *Linker) replace(file []byte, service_prefix string) []byte { prefix := "$1" + strings.TrimSuffix(service_prefix, "/") + "$2" replaced := l.quoted_reg.ReplaceAll(file, []byte(prefix)) - replaced = l.hue_base_url.ReplaceAll(replaced, []byte("window.HUE_BASE_URL +")) + replaced = l.hue_base_url.ReplaceAll(replaced, []byte("window.HUE_BASE_URL")) return replaced } diff --git a/linker_test.go b/linker_test.go index 0d42e29..e6887b9 100644 --- a/linker_test.go +++ b/linker_test.go @@ -32,7 +32,11 @@ func TestLinker(t *testing.T) { }, { `link = window.HUE_BASE_URL+'/hue'+link;`, - `link = window.HUE_BASE_URL +link;`, + `link = window.HUE_BASE_URL+link;`, + }, + { + `page__WEBPACK_IMPORTED_MODULE_3___default().base(window.HUE_BASE_URL + '/hue');`, + `page__WEBPACK_IMPORTED_MODULE_3___default().base(window.HUE_BASE_URL);`, }, }