mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[api] Replace om:// scheme with cm://
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
|
||||
<data android:scheme="geo"/>
|
||||
<data android:scheme="ge0"/>
|
||||
<data android:scheme="om"/>
|
||||
<data android:scheme="cm"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
|
||||
@@ -150,7 +150,7 @@ public class OsmLoginFragment extends BaseMwmToolbarFragment
|
||||
requireActivity().finish();
|
||||
}
|
||||
|
||||
// This method is called by MwmActivity & UrlProcessor when "om://oauth2/osm/callback?code=XXX" is handled
|
||||
// This method is called by MwmActivity & UrlProcessor when "cm://oauth2/osm/callback?code=XXX" is handled
|
||||
private void continueOAuth2Flow(String oauth2code)
|
||||
{
|
||||
if (!isAdded())
|
||||
|
||||
@@ -12,7 +12,7 @@ public final class Constants
|
||||
|
||||
public static class Url
|
||||
{
|
||||
public static final String SHORT_SHARE_PREFIX = "om://";
|
||||
public static final String SHORT_SHARE_PREFIX = "cm://";
|
||||
public static final String HTTP_SHARE_PREFIX = "https://comaps.app/";
|
||||
|
||||
public static final String MAILTO_SCHEME = "mailto:";
|
||||
|
||||
@@ -115,8 +115,8 @@ UNIT_TEST(Url_Valid)
|
||||
.KV("ll", "10.3,12.3223")
|
||||
.KV("n", "Hello World");
|
||||
|
||||
TestUrl("om:M&M//path?q=q&w=w")
|
||||
.Scheme("om")
|
||||
TestUrl("cm:M&M//path?q=q&w=w")
|
||||
.Scheme("cm")
|
||||
.Host("M&M")
|
||||
.Path("path")
|
||||
.KV("q", "q")
|
||||
@@ -127,7 +127,7 @@ UNIT_TEST(Url_Valid)
|
||||
.Host("www.sandwichparlour.com.au")
|
||||
.Path("");
|
||||
|
||||
TestUrl("om:/&test").Scheme("om").Host("&test").Path("");
|
||||
TestUrl("cm:/&test").Scheme("cm").Host("&test").Path("");
|
||||
}
|
||||
|
||||
UNIT_TEST(Url_Fragment)
|
||||
|
||||
@@ -110,7 +110,7 @@ OsmOAuth OsmOAuth::DevServerAuth()
|
||||
constexpr char const * kOsmDevClientId = "Tj8yyx3FWy_N5wz6sUTAXTM6YBAiwVgM7sRLrLix2u8";
|
||||
constexpr char const * kOsmDevClientSecret = "TdEQaoAQkcu_E2HWfr0RDaG5hMDk3gThO1RvWQtQc8o";
|
||||
constexpr char const * kOsmDevScope = "read_prefs write_api write_notes";
|
||||
constexpr char const * kOsmDevRedirectUri = "om://oauth2/osm/callback";
|
||||
constexpr char const * kOsmDevRedirectUri = "cm://oauth2/osm/callback";
|
||||
|
||||
return {kOsmDevClientId, kOsmDevClientSecret, kOsmDevScope, kOsmDevRedirectUri, kOsmDevServer, kOsmDevServer};
|
||||
}
|
||||
|
||||
@@ -255,91 +255,91 @@ UNIT_TEST(LatLonToString_StringDensity)
|
||||
UNIT_TEST(GenerateShortShowMapUrl_SmokeTest)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "Name");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_NameIsEmpty)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "");
|
||||
TEST_EQUAL("om://8wAAAAAAAA", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_ZoomVerySmall)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 2, "Name");
|
||||
TEST_EQUAL("om://AwAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://AwAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_ZoomNegative)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, -5, "Name");
|
||||
TEST_EQUAL("om://AwAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://AwAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_ZoomLarge)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 20, "Name");
|
||||
TEST_EQUAL("om://_wAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://_wAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_ZoomVeryLarge)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 2000000000, "Name");
|
||||
TEST_EQUAL("om://_wAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://_wAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_FractionalZoom)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 8.25, "Name");
|
||||
TEST_EQUAL("om://RwAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://RwAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_FractionalZoomRoundsDown)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 8.499, "Name");
|
||||
TEST_EQUAL("om://RwAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://RwAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_FractionalZoomNextStep)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 8.5, "Name");
|
||||
TEST_EQUAL("om://SwAAAAAAAA/Name", res, ());
|
||||
TEST_EQUAL("cm://SwAAAAAAAA/Name", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_SpaceIsReplacedWithUnderscore)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "Hello World");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/Hello_World", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/Hello_World", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_NamesAreEscaped)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "'Hello,World!%$");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/%27Hello%2CWorld%21%25%24", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/%27Hello%2CWorld%21%25%24", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_UnderscoreIsReplacedWith_Percent_20)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "Hello_World");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/Hello%20World", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/Hello%20World", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_ControlCharsAreEscaped)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "Hello\tWorld\n");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/Hello%09World%0A", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/Hello%09World%0A", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_Unicode)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "\xe2\x98\x84");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/\xe2\x98\x84", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/\xe2\x98\x84", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateShortShowMapUrl_UnicodeMixedWithOtherChars)
|
||||
{
|
||||
string res = GenerateShortShowMapUrl(0, 0, 19, "Back_in \xe2\x98\x84!\xd1\x8e\xd0\xbc");
|
||||
TEST_EQUAL("om://8wAAAAAAAA/Back%20in_\xe2\x98\x84%21\xd1\x8e\xd0\xbc", res, ());
|
||||
TEST_EQUAL("cm://8wAAAAAAAA/Back%20in_\xe2\x98\x84%21\xd1\x8e\xd0\xbc", res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateGeoUri_SmokeTest)
|
||||
|
||||
@@ -34,10 +34,10 @@ bool Ge0Parser::Parse(std::string const & url, Result & result)
|
||||
// |+-------+--------- 9 bytes: lat,lon
|
||||
// || | +--+---- Variable number of bytes: point name
|
||||
// || | | |
|
||||
// om://ZCoordba64/Name
|
||||
// cm://ZCoordba64/Name
|
||||
|
||||
// Alternative format (differs only in the prefix):
|
||||
// http://omaps.app/ZCoordba64/Name
|
||||
// http://comaps.app/ZCoordba64/Name
|
||||
|
||||
for (auto prefix : kGe0Prefixes)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ class Ge0Parser
|
||||
public:
|
||||
// Used by map/mwm_url.cpp.
|
||||
static constexpr std::array<std::string_view, 6> kGe0Prefixes = {{
|
||||
"https://comaps.app/", "om://", "http://comaps.app/",
|
||||
"https://comaps.app/", "cm://", "http://comaps.app/",
|
||||
"ge0://", "http://ge0.me/", "https://ge0.me/"
|
||||
}};
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ namespace ge0
|
||||
{
|
||||
std::string GenerateShortShowMapUrl(double lat, double lon, double zoom, std::string const & name)
|
||||
{
|
||||
size_t constexpr schemaLength = 5; // strlen("om://")
|
||||
std::string urlSample = "om://ZCoordba64";
|
||||
size_t constexpr schemaLength = 5; // strlen("cm://")
|
||||
std::string urlSample = "cm://ZCoordba64";
|
||||
|
||||
int const zoomI = (zoom <= 4 ? 0 : (zoom >= 19.75 ? 63 : static_cast<int>((zoom - 4) * 4)));
|
||||
urlSample[schemaLength] = Base64Char(zoomI);
|
||||
|
||||
@@ -16,7 +16,7 @@ inline static int const kMaxCoordBits = kMaxPointBytes * 3;
|
||||
// |+-------+--------- 9 bytes: lat,lon
|
||||
// || | +--+---- Variable number of bytes: point name
|
||||
// || | | |
|
||||
// om://ZCoordba64/Name
|
||||
// cm://ZCoordba64/Name
|
||||
std::string GenerateShortShowMapUrl(double lat, double lon, double zoomLevel, std::string const & name);
|
||||
|
||||
// Generates a geo: uri.
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
}
|
||||
|
||||
func applicationDidReceiveUniversalLink(_ universalLink: URL) -> Bool {
|
||||
// Convert http(s)://omaps.app/ENCODEDCOORDS/NAME to om://ENCODEDCOORDS/NAME
|
||||
// Convert http(s)://comaps.app/ENCODEDCOORDS/NAME to cm://ENCODEDCOORDS/NAME
|
||||
self.url = URL(string: universalLink.absoluteString
|
||||
.replacingOccurrences(of: "http://omaps.app", with: "om:/")
|
||||
.replacingOccurrences(of: "https://omaps.app", with: "om:/"))
|
||||
.replacingOccurrences(of: "http://comaps.app", with: "cm:/")
|
||||
.replacingOccurrences(of: "https://comaps.app", with: "cm:/"))
|
||||
isLaunchedByUniversalLink = true
|
||||
return handleDeepLink(url: self.url!)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ UNIT_TEST(SearchApiAdvanced)
|
||||
{
|
||||
{
|
||||
// Ignore wrong cll=.
|
||||
ParsedMapApi test("om://search?query=aaa&cll=1,1,1");
|
||||
ParsedMapApi test("cm://search?query=aaa&cll=1,1,1");
|
||||
TEST_EQUAL(test.GetRequestType(), UrlType::Search, ());
|
||||
auto const & request = test.GetSearchRequest();
|
||||
ms::LatLon latlon = test.GetCenterLatLon();
|
||||
@@ -91,7 +91,7 @@ UNIT_TEST(SearchApiAdvanced)
|
||||
|
||||
{
|
||||
// Don't fail on unsupported parameters.
|
||||
ParsedMapApi test("om://search?query=aaa&ignoreThisParam=sure");
|
||||
ParsedMapApi test("cm://search?query=aaa&ignoreThisParam=sure");
|
||||
TEST_EQUAL(test.GetRequestType(), UrlType::Search, ());
|
||||
auto const & request = test.GetSearchRequest();
|
||||
ms::LatLon latlon = test.GetCenterLatLon();
|
||||
@@ -104,7 +104,7 @@ UNIT_TEST(SearchApiAdvanced)
|
||||
|
||||
{
|
||||
// Query parameter position doesn't matter
|
||||
ParsedMapApi test("om://search?cll=1,1&locale=ru&query=aaa");
|
||||
ParsedMapApi test("cm://search?cll=1,1&locale=ru&query=aaa");
|
||||
TEST_EQUAL(test.GetRequestType(), UrlType::Search, ());
|
||||
auto const & request = test.GetSearchRequest();
|
||||
ms::LatLon latlon = test.GetCenterLatLon();
|
||||
@@ -256,7 +256,7 @@ UNIT_TEST(MapApiUrl)
|
||||
UNIT_TEST(MapApiGe0)
|
||||
{
|
||||
{
|
||||
ParsedMapApi api("om://o4B4pYZsRs");
|
||||
ParsedMapApi api("cm://o4B4pYZsRs");
|
||||
TEST_EQUAL(api.GetRequestType(), UrlType::Map, ());
|
||||
TEST_EQUAL(api.GetMapPoints().size(), 1, ());
|
||||
MapPoint const & p0 = api.GetMapPoints()[0];
|
||||
@@ -265,7 +265,7 @@ UNIT_TEST(MapApiGe0)
|
||||
}
|
||||
|
||||
{
|
||||
ParsedMapApi api("om://o4B4pYZsRs/Zoo_Zürich");
|
||||
ParsedMapApi api("cm://o4B4pYZsRs/Zoo_Zürich");
|
||||
TEST_EQUAL(api.GetRequestType(), UrlType::Map, ());
|
||||
TEST_EQUAL(api.GetMapPoints().size(), 1, ());
|
||||
MapPoint const & p0 = api.GetMapPoints()[0];
|
||||
@@ -368,7 +368,7 @@ UNIT_TEST(SearchApiGeoScheme)
|
||||
UNIT_TEST(CrosshairApi)
|
||||
{
|
||||
{
|
||||
ParsedMapApi api("om://crosshair?cll=47.3813,8.5889&appname=Google%20Maps");
|
||||
ParsedMapApi api("cm://crosshair?cll=47.3813,8.5889&appname=Google%20Maps");
|
||||
TEST_EQUAL(api.GetRequestType(), UrlType::Crosshair, ());
|
||||
ms::LatLon latlon = api.GetCenterLatLon();
|
||||
TEST_ALMOST_EQUAL_ABS(latlon.m_lat, 47.3813, kEps, ());
|
||||
@@ -397,8 +397,8 @@ UNIT_TEST(GlobalBackUrl)
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "ge0://", ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("om://map?ll=1,2&n=PointName&backurl=om://");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "om://", ());
|
||||
ParsedMapApi api("cm://map?ll=1,2&n=PointName&backurl=cm://");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "cm://", ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("mwm://map?ll=1,2&n=PointName&backurl=ge0%3A%2F%2F");
|
||||
@@ -477,16 +477,16 @@ UNIT_TEST(AppNameTest)
|
||||
UNIT_TEST(OAuth2Test)
|
||||
{
|
||||
{
|
||||
ParsedMapApi api("om://oauth2/osm/callback?code=THE_MEGA_CODE");
|
||||
ParsedMapApi api("cm://oauth2/osm/callback?code=THE_MEGA_CODE");
|
||||
TEST_EQUAL(api.GetRequestType(), UrlType::OAuth2, ());
|
||||
TEST_EQUAL(api.GetOAuth2Code(), "THE_MEGA_CODE", ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("om://oauth2/google/callback?code=THE_MEGA_CODE");
|
||||
ParsedMapApi api("cm://oauth2/google/callback?code=THE_MEGA_CODE");
|
||||
TEST_EQUAL(api.GetRequestType(), UrlType::Incorrect, ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("om://oauth2/osm/callback?code=");
|
||||
ParsedMapApi api("cm://oauth2/osm/callback?code=");
|
||||
TEST_EQUAL(api.GetRequestType(), UrlType::Incorrect, ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ ParsedMapApi::UrlType ParsedMapApi::SetUrlAndParse(std::string const & raw)
|
||||
|
||||
if (auto const [prefix, checkForGe0Link] = FindUrlPrefix(raw); prefix != std::string::npos)
|
||||
{
|
||||
url::Url const url {"om://" + raw.substr(prefix)};
|
||||
url::Url const url {"cm://" + raw.substr(prefix)};
|
||||
if (!url.IsValid())
|
||||
return m_requestType = UrlType::Incorrect;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#define OSM_OAUTH2_CLIENT_ID "P10w0BFkJ2-IoV2tg94biU-x9grsbGnw072Ud-kMcUc"
|
||||
#define OSM_OAUTH2_CLIENT_SECRET "3l3AjaFW7sJRKM4sOF0MrdBEpbm5XjCeCFDULFfu8vY"
|
||||
#define OSM_OAUTH2_REDIRECT_URI "om://oauth2/osm/callback"
|
||||
#define OSM_OAUTH2_REDIRECT_URI "cm://oauth2/osm/callback"
|
||||
#define OSM_OAUTH2_SCOPE "read_prefs write_api write_notes"
|
||||
#define MWM_GEOLOCATION_SERVER ""
|
||||
#define DIFF_LIST_URL ""
|
||||
|
||||
@@ -12,7 +12,7 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(levelname)-5s] %
|
||||
osmHost = "www.openstreetmap.org"
|
||||
OAuthClientId = "nw9bW3nZ-q99SXzgnH-dlED3ueDSmFPtxl33n3hDwFU"
|
||||
OAuthClientSecret = "nIxwFx1NXIx9lKoNmb7lAoHd9ariGMf46PtU_YG558c"
|
||||
OAuthRedirectUri = "om://oauth2/osm/callback"
|
||||
OAuthRedirectUri = "cm://oauth2/osm/callback"
|
||||
OAuthResponseType = "code"
|
||||
OAuthScope = "read_prefs"
|
||||
"""
|
||||
@@ -21,10 +21,10 @@ OAuthScope = "read_prefs"
|
||||
osmHost = "master.apis.dev.openstreetmap.org"
|
||||
OAuthClientId = "uB0deHjh_W86CRUHfvWlisCC1ZIHkdLoKxz1qkuIrrM"
|
||||
OAuthClientSecret = "xQE7suO-jmzmels19k-m8FQ8gHnkdWuLLVqfW6FIj44"
|
||||
OAuthRedirectUri = "om://oauth2/osm/callback"
|
||||
OAuthRedirectUri = "cm://oauth2/osm/callback"
|
||||
OAuthResponseType = "code"
|
||||
OAuthScope = "read_prefs write_api write_notes"
|
||||
test_login = "OrganicMapsTestUser"
|
||||
test_login = "CoMapsTestUser"
|
||||
test_password = "12345678"
|
||||
|
||||
def FetchSessionId():
|
||||
|
||||
Reference in New Issue
Block a user