From cc9d16f505f4b3108e54efa4bff698dd3bd2be91 Mon Sep 17 00:00:00 2001 From: anqiansong Date: Sat, 12 Mar 2022 22:21:17 +0800 Subject: [PATCH] fix: Update unix-like path regex (#1637) * Revert import value regex * Update linux path regex Co-authored-by: anqiansong --- tools/goctl/api/parser/g4/gen/api/baseparser.go | 2 +- tools/goctl/api/parser/g4/gen/api/baseparser_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/goctl/api/parser/g4/gen/api/baseparser.go b/tools/goctl/api/parser/g4/gen/api/baseparser.go index 32b53093..41f486f1 100644 --- a/tools/goctl/api/parser/g4/gen/api/baseparser.go +++ b/tools/goctl/api/parser/g4/gen/api/baseparser.go @@ -12,7 +12,7 @@ import ( const ( versionRegex = `(?m)"v[1-9][0-9]*"` - importValueRegex = `(?m)"\/?(([a-zA-Z0-9.]+)+(\/?){1})+([a-zA-Z0-9]+)+\.api"` + importValueRegex = `(?m)"\/?(?:[^/]+\/)*[^/]+.api"` tagRegex = `(?m)\x60[a-z]+:".+"\x60` ) diff --git a/tools/goctl/api/parser/g4/gen/api/baseparser_test.go b/tools/goctl/api/parser/g4/gen/api/baseparser_test.go index 9cd29ca7..1d3dbe79 100644 --- a/tools/goctl/api/parser/g4/gen/api/baseparser_test.go +++ b/tools/goctl/api/parser/g4/gen/api/baseparser_test.go @@ -23,6 +23,7 @@ func TestImportRegex(t *testing.T) { {`"bar..api"`, false}, {`"//bar.api"`, false}, + {`"/foo/foo_bar.api"`, true}, } for _, tt := range tests { t.Run(tt.value, func(t *testing.T) {