Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCORE-2096 Trim trailing slashes from base urls to prevent 404 errors #7791

Merged
merged 4 commits into from
Jun 13, 2024

Conversation

jbreams
Copy link
Contributor

@jbreams jbreams commented Jun 10, 2024

What, How & Why?

This fixes a gotcha where if you set your base url to "https://example.com/" instead of "https://example.com" it will be interpretted as "https://example.com//path/to/app" which results in a 404 error from the server.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed
  • bindgen/spec.yml, if public C++ API changed

@@ -157,6 +157,24 @@ HttpHeaders get_request_headers(const std::shared_ptr<User>& user, RequestTokenT
return headers;
}

std::string trim_base_url(std::string base_url)
{
while (base_url.back() == '/') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the base_url should not be empty, but it's undefined behaviour to call back() if empty() is true. we should add a guard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link

coveralls-official bot commented Jun 10, 2024

Pull Request Test Coverage Report for Build jonathan.reams_3267

Details

  • 50 of 50 (100.0%) changed or added relevant lines in 2 files are covered.
  • 140 unchanged lines in 13 files lost coverage.
  • Overall coverage decreased (-0.04%) to 90.934%

Files with Coverage Reduction New Missed Lines %
src/realm/util/file.cpp 1 84.84%
test/test_index_string.cpp 1 93.48%
src/realm/cluster.cpp 2 75.6%
src/realm/db.cpp 2 92.05%
test/test_all.cpp 2 75.82%
src/realm/sync/noinst/protocol_codec.hpp 3 73.5%
src/realm/unicode.cpp 3 83.83%
src/realm/bplustree.cpp 6 72.55%
src/realm/sync/noinst/server/server_history.cpp 6 63.38%
src/realm/sync/noinst/client_impl_base.cpp 10 82.07%
Totals Coverage Status
Change from base Build 2405: -0.04%
Covered Lines: 214564
Relevant Lines: 235956

💛 - Coveralls

Copy link

coveralls-official bot commented Jun 13, 2024

Pull Request Test Coverage Report for Build jonathan.reams_3271

Details

  • 50 of 50 (100.0%) changed or added relevant lines in 2 files are covered.
  • 74 unchanged lines in 16 files lost coverage.
  • Overall coverage increased (+0.005%) to 90.98%

Files with Coverage Reduction New Missed Lines %
src/realm/index_string.hpp 1 93.48%
src/realm/mixed.cpp 1 86.46%
src/realm/util/file.cpp 1 84.84%
src/realm/uuid.cpp 1 98.48%
src/realm/sync/transform.cpp 2 60.99%
src/realm/table_view.cpp 2 92.99%
test/test_lang_bind_helper.cpp 2 93.2%
src/realm/sync/noinst/server/server_history.cpp 3 63.51%
src/realm/util/future.hpp 3 95.94%
src/realm/sync/noinst/protocol_codec.hpp 4 73.32%
Totals Coverage Status
Change from base Build 2417: 0.005%
Covered Lines: 214792
Relevant Lines: 236086

💛 - Coveralls

@jbreams jbreams merged commit d4ec79b into master Jun 13, 2024
39 checks passed
@jbreams jbreams deleted the jbr/base_url_trailing_slash branch June 13, 2024 18:22
@github-actions github-actions bot mentioned this pull request Jun 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants