[core] add util::isURL() for checking whether a string starts with a URL scheme

This commit is contained in:
Konstantin Käfer
2016-12-06 14:44:55 +01:00
parent cc6e5c9df9
commit dc1bda435f
4 changed files with 60 additions and 2 deletions

25
test/util/url.test.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include <mbgl/test/util.hpp>
#include <mbgl/util/url.hpp>
#include <memory>
using namespace mbgl::util;
TEST(URL, isURL) {
EXPECT_TRUE(isURL("mapbox://foo"));
EXPECT_TRUE(isURL("mapbox://"));
EXPECT_TRUE(isURL("mapbox-test-scheme://foo"));
EXPECT_TRUE(isURL("mapbox+style://foo"));
EXPECT_TRUE(isURL("mapbox-2.0://foo"));
EXPECT_TRUE(isURL("mapbox99://foo"));
EXPECT_FALSE(isURL("mapbox:/"));
EXPECT_FALSE(isURL(" mapbox://"));
EXPECT_FALSE(isURL("://"));
EXPECT_FALSE(isURL("mapbox"));
EXPECT_FALSE(isURL("mapbox:foo"));
EXPECT_FALSE(isURL("mapbox:/foo"));
EXPECT_FALSE(isURL("test/mapbox://foo"));
EXPECT_FALSE(isURL("123://foo"));
}