From 14de12903c3a29184360ce3f593c0b5926e6d89e Mon Sep 17 00:00:00 2001 From: Moh Achun Armando Date: Fri, 17 Jan 2025 15:28:23 +0700 Subject: [PATCH 1/3] hotfix: change IsURLReachable status code rule --- CHANGELOG.md | 24 ++++++++++++------------ url.go | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb4b655..03b048a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # go-utils + +## [v1.39.6] - 0001-01-01 + ## [v1.39.5] - 2024-12-19 ### Fixes @@ -174,9 +177,6 @@ ## [v1.20.0] - 2022-03-11 - - -## [v.1.20.0] - 2022-03-11 ### New Features - add constraint size gql directive ([#30](https://github.com/kumparan/go-utils/issues/30)) @@ -274,11 +274,11 @@ - add money formatter for multiple currencies ([#13](https://github.com/kumparan/go-utils/issues/13)) - -## [v1.7.1] - 2020-12-10 - ## [v1.8.0] - 2020-12-10 + + +## [v1.7.1] - 2020-12-10 ### New Features - add formatter for indonesian money and date @@ -343,7 +343,8 @@ - init go-utils -[Unreleased]: https://github.com/kumparan/go-utils/compare/v1.39.5...HEAD +[Unreleased]: https://github.com/kumparan/go-utils/compare/v1.39.6...HEAD +[v1.39.6]: https://github.com/kumparan/go-utils/compare/v1.39.5...v1.39.6 [v1.39.5]: https://github.com/kumparan/go-utils/compare/v1.39.4...v1.39.5 [v1.39.4]: https://github.com/kumparan/go-utils/compare/v1.39.3...v1.39.4 [v1.39.3]: https://github.com/kumparan/go-utils/compare/v1.39.2...v1.39.3 @@ -372,8 +373,7 @@ [v1.22.0]: https://github.com/kumparan/go-utils/compare/v1.21.0...v1.22.0 [v1.21.0]: https://github.com/kumparan/go-utils/compare/v1.20.1...v1.21.0 [v1.20.1]: https://github.com/kumparan/go-utils/compare/v1.20.0...v1.20.1 -[v1.20.0]: https://github.com/kumparan/go-utils/compare/v.1.20.0...v1.20.0 -[v.1.20.0]: https://github.com/kumparan/go-utils/compare/v1.19.3...v.1.20.0 +[v1.20.0]: https://github.com/kumparan/go-utils/compare/v1.19.3...v1.20.0 [v1.19.3]: https://github.com/kumparan/go-utils/compare/v1.19.2...v1.19.3 [v1.19.2]: https://github.com/kumparan/go-utils/compare/v1.19.1...v1.19.2 [v1.19.1]: https://github.com/kumparan/go-utils/compare/v1.19.0...v1.19.1 @@ -389,9 +389,9 @@ [v1.12.0]: https://github.com/kumparan/go-utils/compare/v1.11.0...v1.12.0 [v1.11.0]: https://github.com/kumparan/go-utils/compare/v1.10.0...v1.11.0 [v1.10.0]: https://github.com/kumparan/go-utils/compare/v1.9.0...v1.10.0 -[v1.9.0]: https://github.com/kumparan/go-utils/compare/v1.7.1...v1.9.0 -[v1.7.1]: https://github.com/kumparan/go-utils/compare/v1.8.0...v1.7.1 -[v1.8.0]: https://github.com/kumparan/go-utils/compare/v1.7.0...v1.8.0 +[v1.9.0]: https://github.com/kumparan/go-utils/compare/v1.8.0...v1.9.0 +[v1.8.0]: https://github.com/kumparan/go-utils/compare/v1.7.1...v1.8.0 +[v1.7.1]: https://github.com/kumparan/go-utils/compare/v1.7.0...v1.7.1 [v1.7.0]: https://github.com/kumparan/go-utils/compare/v1.6.0...v1.7.0 [v1.6.0]: https://github.com/kumparan/go-utils/compare/v1.5.0...v1.6.0 [v1.5.0]: https://github.com/kumparan/go-utils/compare/v1.4.0...v1.5.0 diff --git a/url.go b/url.go index e595127..058e951 100644 --- a/url.go +++ b/url.go @@ -31,5 +31,6 @@ func IsURLReachable(url string) bool { _ = res.Body.Close() }() - return res.StatusCode == http.StatusOK + log.Infof("statusCode: %d", res.StatusCode) + return res.StatusCode < 500 } From 6d081cc2b1dd590e5357326a1dfc80e4daad2b17 Mon Sep 17 00:00:00 2001 From: Moh Achun Armando Date: Fri, 17 Jan 2025 15:28:40 +0700 Subject: [PATCH 2/3] bump: changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b048a..f4269ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # go-utils -## [v1.39.6] - 0001-01-01 +## [v1.39.6] - 2025-01-17 +### Fixes +- change IsURLReachable status code rule + ## [v1.39.5] - 2024-12-19 From 5eefeefb6a318c3cfff9a4d42bdefc14303f7d90 Mon Sep 17 00:00:00 2001 From: Moh Achun Armando Date: Fri, 17 Jan 2025 15:34:38 +0700 Subject: [PATCH 3/3] add test --- url_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/url_test.go b/url_test.go index 1cc9c13..eb80e84 100644 --- a/url_test.go +++ b/url_test.go @@ -70,6 +70,13 @@ func Test_JoinURL(t *testing.T) { } func TestIsURLReachable(t *testing.T) { + t.Run("should return true on valid + reachable url", func(t *testing.T) { + url := "https://docs.google.com/spreadsheets/d/1IJ3C-U-N8OqIlk1pZoGyKadTPowiJIhWla4CQMFh9NQ/edit?gid=1131639184#gid=1131639184" + + res := IsURLReachable(url) + assert.True(t, res) + }) + t.Run("should return true on valid + reachable url", func(t *testing.T) { url := "https://google.com"