Explorar el Código

refactor(mediaproxy): simplify shouldProxy

The original function was non-trivial to understand, as `!A && (B || !C)` isn't
easily grokable by humans.
jvoisin hace 9 meses
padre
commit
f864a2ed70
Se han modificado 1 ficheros con 10 adiciones y 2 borrados
  1. 10 2
      internal/mediaproxy/rewriter.go

+ 10 - 2
internal/mediaproxy/rewriter.go

@@ -108,6 +108,14 @@ func proxifySourceSet(element *goquery.Selection, router *mux.Router, proxifyFun
 }
 }
 
 
 func shouldProxy(attrValue, proxyOption string) bool {
 func shouldProxy(attrValue, proxyOption string) bool {
-	return !strings.HasPrefix(attrValue, "data:") &&
-		(proxyOption == "all" || !urllib.IsHTTPS(attrValue))
+	if strings.HasPrefix(attrValue, "data:") {
+		return false
+	}
+	if proxyOption == "all" {
+		return true
+	}
+	if !urllib.IsHTTPS(attrValue) {
+		return true
+	}
+	return false
 }
 }