From 5cfd146fcbc317d029099e2f863712fcecebdfca Mon Sep 17 00:00:00 2001 From: Richardas Kuchinskas Date: Sun, 28 Jul 2024 11:07:32 +0300 Subject: [PATCH] rewrote link url checker logic --- src/rules/parser.go | 2 +- src/tests/rules/rules_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rules/parser.go b/src/rules/parser.go index f18870ba..6fa88e53 100644 --- a/src/rules/parser.go +++ b/src/rules/parser.go @@ -349,7 +349,7 @@ func (p *parser) parseRuleInfo(st ir.Node, labelStmt ir.Node, proto *Rule) (Rule } func isURL(str string) bool { - re := regexp.MustCompile(`^(https?|ftp)://[^\s/$.?#].\S*$`) + re := regexp.MustCompile(`^((https?|ftp)://)?[^\s/$.?#].[^\s]*$`) return re.MatchString(str) } diff --git a/src/tests/rules/rules_test.go b/src/tests/rules/rules_test.go index 02a2df5f..eea8f280 100644 --- a/src/tests/rules/rules_test.go +++ b/src/tests/rules/rules_test.go @@ -338,7 +338,7 @@ func TestLinkTag(t *testing.T) { * @name emptyIf * @warning suspicious empty body of the if statement * @scope local - * @link https://goodrule.com + * @link goodrule.com */ if ($_); ` @@ -354,7 +354,7 @@ function f() { `) test.Expect = []string{ - ` | More about this rule: https://goodrule.com`, + ` | More about this rule: goodrule.com`, } test.RunRulesTest() }