Browse Source

Fix spaces in html code

Volodymyr Tkach 2 years ago
parent
commit
4c755a3c54
2 changed files with 8 additions and 2 deletions
  1. 2 2
      utils/http/helpers/helpers.go
  2. 6 0
      utils/http/helpers/helpers_test.go

+ 2 - 2
utils/http/helpers/helpers.go

@@ -23,8 +23,8 @@ import (
 // func SetLanguageCookie(w http.ResponseWriter, r *http.Request) error
 // func SetLanguageCookie(w http.ResponseWriter, r *http.Request) error
 
 
 var mHtml = regexp.MustCompile(`>[\n\t\r\s]+<`)
 var mHtml = regexp.MustCompile(`>[\n\t\r\s]+<`)
-var mHtmlLeft = regexp.MustCompile(`>[\n\t\r\s]+`)
-var mHtmlRight = regexp.MustCompile(`[\n\t\r\s]+<`)
+var mHtmlLeft = regexp.MustCompile(`>[\n\t\r]+`)
+var mHtmlRight = regexp.MustCompile(`[\n\t\r]+<`)
 
 
 func HandlerApplicationStatus() http.Handler {
 func HandlerApplicationStatus() http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

+ 6 - 0
utils/http/helpers/helpers_test.go

@@ -22,6 +22,12 @@ var _ = Describe("helpers", func() {
 					</body>
 					</body>
 				</html>
 				</html>
 			`)).To(Equal(`<!doctype html><html lang="uk"><head><meta charset="utf-8" /></head><body>Index</body></html>`))
 			`)).To(Equal(`<!doctype html><html lang="uk"><head><meta charset="utf-8" /></head><body>Index</body></html>`))
+
+			Expect(helpers.MinifyHtmlCode(`
+				<div>
+					<a href="#">Link 1</a>, <a href="#">Link 2</a>
+				</div>
+			`)).To(Equal(`<div><a href="#">Link 1</a>, <a href="#">Link 2</a></div>`))
 		})
 		})
 	})
 	})
 })
 })