fixed provider url generation

This commit is contained in:
javi 2013-10-10 10:59:19 +02:00
parent fd03f92b83
commit d0ab61ef6d
4 changed files with 25 additions and 1 deletions

View File

@ -127,7 +127,11 @@
},
url: function() {
return this.options.url || 'http://' + this.options.user + '.cartodb.com/api/v2/sql';
var opts = this.options;
var port = opts.sql_api_port;
var domain = (opts.sql_api_domain || (this.options.user + '.cartodb.com')) + (port ? ':' + port: '');
var protocol = opts.sql_api_protocol || 'http';
return this.options.url || protocol + '://' + domain + '/api/v2/sql';
},
// execute actual query

14
test/provider.json.js Normal file
View File

@ -0,0 +1,14 @@
module('provider.json');
test("url", function() {
var json = new torque.providers.json({
user: "rambo",
resolution: 1,
steps: 10
});
equal("http://rambo.cartodb.com/api/v2/sql", json.url());
});

View File

@ -1,4 +1,6 @@
module('provider.jsonarray');
test("processTile", function() {
var json = new torque.providers.JsonArray({
url: "http://test.com/{z}/{x}/{y}.json"

View File

@ -10,9 +10,13 @@
<div id="qunit-fixture"></div>
<script src="vendor/qunit.js"></script>
<script src="../lib/torque/core.js"></script>
<script src="../lib/torque/request.js"></script>
<script src="../lib/torque/provider.jsonarray.js"></script>
<script src="../lib/torque/provider.json.js"></script>
<script src="data/torque.array.json"></script>
<script src="provider.jsonarray.js"></script>
<script src="provider.json.js"></script>
</body>
</html>