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

Refactor URL parsing code - #7464

Merged
kkaefer merged 1 commit into
masterfrom
7464-refactor-url-parsing
Dec 21, 2016
Merged

kkaefer merged 1 commit into
masterfrom
7464-refactor-url-parsing

Conversation

@kkaefer

@kkaefer kkaefer commented Dec 16, 2016

Copy link
Copy Markdown
Member

An attempt at #6183.

@mention-bot

Copy link
Copy Markdown

@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
Comment thread src/mbgl/util/mapbox.cpp
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
Copy Markdown
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
Copy Markdown
Contributor

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

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

TEST(Path, Extension) {

Copy link
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
kkaefer force-pushed the 7464-refactor-url-parsing branch from b5d528f to 5a544b6 Compare December 20, 2016 10:56
@kkaefer

kkaefer commented Feb 13, 2017

Copy link
Copy Markdown
Member Author

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