forked from mapbox/mapbox.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
url.js
42 lines (31 loc) · 1.39 KB
/
url.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var config = require('./config'),
version = require('../package.json').version;
module.exports = function(path, accessToken) {
accessToken = accessToken || L.mapbox.accessToken;
if (!accessToken && config.REQUIRE_ACCESS_TOKEN) {
throw new Error('An API access token is required to use Mapbox.js. ' +
'See https://www.mapbox.com/mapbox.js/api/v' + version + '/api-access-tokens/');
}
var url = ('https:' === document.location.protocol || config.FORCE_HTTPS) ? config.HTTPS_URL : config.HTTP_URL;
url += path;
url += url.indexOf('?') !== -1 ? '&access_token=' : '?access_token=';
if (config.REQUIRE_ACCESS_TOKEN) {
if (accessToken[0] === 's') {
throw new Error('Use a public access token (pk.*) with Mapbox.js, not a secret access token (sk.*). ' +
'See https://www.mapbox.com/mapbox.js/api/v' + version + '/api-access-tokens/');
}
url += accessToken;
}
return url;
};
module.exports.tileJSON = function(urlOrMapID, accessToken) {