Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/OsmApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function test_url_to_api() {
$this->assertEquals(url_to_api('/api/0.6/node/123'), 'https://api.openstreetmap.org/api/0.6/node/123');

$this->assertEquals(url_to_api('overpass-api.de/api/interpreter?data=a-long-query'), 'http://overpass-api.de/api/interpreter?data=a-long-query');
$this->assertEquals(url_to_api('overpass.private.coffee/api/interpreter?data=a-long-query'), 'https://overpass.private.coffee/api/interpreter?data=a-long-query');
$this->assertEquals(url_to_api('overpass.osm.jp/api/interpreter?data=a-long-query'), 'https://overpass.osm.jp/api/interpreter?data=a-long-query');
$this->assertEquals(url_to_api('maps.mail.ru/osm/tools/overpass/api/interpreter?data=a-long-query'), 'https://maps.mail.ru/osm/tools/overpass/api/interpreter?data=a-long-query');

$this->assertEquals(
url_to_api('n12,w34,r56'),
Expand Down
1 change: 1 addition & 0 deletions test/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function testPage()

// Button "Show osmChange"
$this->elementByCSS('input[name="showosc"]')->click();
sleep(2);
$this->assertStringContainsString('this will be uploaded to the server', $this->webDriver->getPageSource());
$this->assertMatchesRegularExpression('/<osmChange [^&]+>\s*<\/osmChange>/', $this->webDriver->getPageSource());
}
Expand Down
7 changes: 7 additions & 0 deletions www/osmapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ function url_to_api( $url ) {
)));
if( preg_match('!(?:'.$overpass_re.')/interpreter\?data=.+$!', $url, $m) )
return 'http://'.$m[0];
# Overpass API
$overpass_re_https = str_replace('.', '\\.', implode('|', array(
'overpass.private.coffee/api' , 'overpass.osm.jp/api', 'maps.mail.ru/osm/tools/overpass/api'
)));
if( preg_match('!(?:'.$overpass_re_https.')/interpreter\?data=.+$!', $url, $m) )
return 'https://'.$m[0];


# List of objects
if( preg_match('#^!?\\s*[a-y]+[/\\s]*[0-9.]+[!*]?(?:\\s*,\\s*[a-y]+[/\\s]*[0-9.]+[!*]?)*$#', $url) ) {
Expand Down