From 8fbe59e75fa75cc6d89eac296f44341a574dfb26 Mon Sep 17 00:00:00 2001 From: 0fatal <72899968+0fatal@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:11:02 +0800 Subject: [PATCH] fix: try path failed with folder (#5) * fix: try path failed with folder * doc: update conf --- go-plugins/cmd/go-runner/plugins/try_path.go | 6 +++--- go-plugins/plugins.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go-plugins/cmd/go-runner/plugins/try_path.go b/go-plugins/cmd/go-runner/plugins/try_path.go index 9f2cb1e..335bdf3 100644 --- a/go-plugins/cmd/go-runner/plugins/try_path.go +++ b/go-plugins/cmd/go-runner/plugins/try_path.go @@ -83,8 +83,8 @@ func tryPath(host, path string) (bool, error) { return false, err } defer resp.Body.Close() - if resp.StatusCode != 404 && resp.StatusCode != 403 { - return true, nil + if resp.StatusCode == 404 || resp.StatusCode == 403 || resp.StatusCode == 400 || resp.Header.Get("Content-Type") == "folder" { + return false, nil } - return false, nil + return true, nil } diff --git a/go-plugins/plugins.md b/go-plugins/plugins.md index a99d308..65cbae0 100644 --- a/go-plugins/plugins.md +++ b/go-plugins/plugins.md @@ -14,6 +14,6 @@ value: value is a string (serialized JSON object) that contains `paths` and `hos ```json { "name": "try-path", - "value": "{\"path\":[\"$uri\",\"$uri/\",\"index.html\"],\"host\":\"http://hostname\"}" + "value": "{\"paths\":[\"$uri\", \"$uri/\", \"$uriindex.html\", \"$uri/index.html\"], \"host\":\"http://hostname\"}" } ``` \ No newline at end of file