From e4838c9619302b23569b79309bd2a58e19c6e5f3 Mon Sep 17 00:00:00 2001 From: Amr Saber Date: Sun, 17 Sep 2023 00:29:34 +0100 Subject: [PATCH 1/2] update gh workflow and gorelease configurations --- .github/workflows/{build.yaml => release.yaml} | 12 ++++++------ .github/workflows/{tests.yaml => test.yaml} | 5 ++--- .goreleaser.yaml | 2 -- 3 files changed, 8 insertions(+), 11 deletions(-) rename .github/workflows/{build.yaml => release.yaml} (82%) rename .github/workflows/{tests.yaml => test.yaml} (87%) diff --git a/.github/workflows/build.yaml b/.github/workflows/release.yaml similarity index 82% rename from .github/workflows/build.yaml rename to .github/workflows/release.yaml index 929d38b..d875998 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/release.yaml @@ -3,21 +3,21 @@ name: Build on: push: tags: - - 'v*' + - "v*" jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.21 - name: Cache Go modules uses: actions/cache@v1 @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: go mod download - - name: Docker Login + - name: Container Registry Login uses: docker/login-action@v1 with: registry: ghcr.io @@ -41,6 +41,6 @@ jobs: uses: goreleaser/goreleaser-action@v2 with: version: latest - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.PAT }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/test.yaml similarity index 87% rename from .github/workflows/tests.yaml rename to .github/workflows/test.yaml index fbd30e3..3f1896f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/test.yaml @@ -1,7 +1,6 @@ name: Run tests -on: - push +on: push jobs: run-tests: @@ -14,7 +13,7 @@ jobs: - name: Setup go uses: actions/setup-go@v3 with: - go-version: '1.18' + go-version: 1.21 - name: Run tests run: go test -v -race -timeout 5s ./... diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c5db264..a4938f3 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -25,8 +25,6 @@ builds: archives: - format: binary name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}' - replacements: - darwin: macOS dockers: - dockerfile: goreleaser.dockerfile From ad6e8647b40728e23c93b91651dc49831c603e5c Mon Sep 17 00:00:00 2001 From: Amr Saber Date: Sun, 17 Sep 2023 01:42:23 +0100 Subject: [PATCH 2/2] fix bug with resolving redirection destination wildcard --- src/models/redirect.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/redirect.go b/src/models/redirect.go index c52ed5e..bd17fe1 100644 --- a/src/models/redirect.go +++ b/src/models/redirect.go @@ -17,9 +17,9 @@ type Redirect struct { func (redirect Redirect) ResolvePath(request *http.Request) string { toUrl, _ := url.Parse(redirect.To) - if strings.Contains(toUrl.Hostname(), "*") { - toSections := strings.Split(toUrl.Hostname(), ".") - requestSections := strings.Split(request.URL.Hostname(), ".") + if strings.Contains(toUrl.Host, "*") { + toSections := strings.Split(toUrl.Host, ".") + requestSections := strings.Split(request.Host, ".") // Substitute every * in to with corresponding section in request for i, section := range toSections {