Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Refactor URL parsing code #7464

Merged
merged 1 commit into from
Dec 21, 2016
Merged

Refactor URL parsing code #7464

merged 1 commit into from
Dec 21, 2016

Conversation

kkaefer
Copy link
Contributor

@kkaefer kkaefer commented Dec 16, 2016

An attempt at #6183.

@mention-bot
Copy link

@kkaefer, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @tmcw and @yhahn to be potential reviewers.

@kkaefer kkaefer force-pushed the 7464-refactor-url-parsing branch 2 times, most recently from 9f28972 to b5d528f Compare December 19, 2016 12:55
if (extensionIdx == std::string::npos || extensionIdx == queryIdx - 1) {
return url;
std::string
canonicalizeTileURL(const std::string& str, const SourceType type, const uint16_t tileSize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The prior version of canonicalizeTileURL wasn't restricted to *.mapbox.com, right? It definitely needs to continue to support *.mapbox.cn (we should add a test for this) and should likely continue to support arbitrary/staging hostnames as well. It's only used in situations where the source URL is mapbox://..., so I don't think enforcing a particular hostname is necessary.

@jfirebaugh
Copy link
Contributor

👍 on URL/Path -- seems like a good middle ground between ad hoc parsing and a full blown RFC compliant library.

EXPECT_EQ(Path::Segment({ 18, 0 }), URLPath("http://example.com?query=foo.bar").directory);
}

TEST(Path, Extension) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have a test for double extensions (e.g. .vector.pbf).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it's debatable on what constitutes an extension and what is part of the filename. For a (hypothetical) URL of mapbox://sources/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7, would the extension be nothing? or .mapbox-terrain-v2,mapbox.mapbox-streets-v7?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you went with "the final period and everything following". Seems good to me!

@kkaefer
Copy link
Contributor Author

kkaefer commented Feb 13, 2017

For reference, here's an insightful article by the author of cURL on why RFC compliance for URL parsing doesn't work: https://daniel.haxx.se/blog/2016/05/11/my-url-isnt-your-url/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants