Merge pull request #2681 from frewsxcv/patch-1

Use HTTPS if location protocol is HTTPS in iD.Connection
This commit is contained in:
Bryan Housel
2015-07-17 15:01:26 -04:00
2 changed files with 21 additions and 4 deletions

View File

@@ -1,12 +1,17 @@
iD.Connection = function() {
iD.Connection = function(useHttps) {
if (typeof useHttps !== 'boolean') {
useHttps = window.location.protocol === 'https:';
}
var event = d3.dispatch('authenticating', 'authenticated', 'auth', 'loading', 'loaded'),
url = 'http://www.openstreetmap.org',
protocol = useHttps ? 'https:' : 'http:',
url = protocol + '//www.openstreetmap.org',
connection = {},
inflight = {},
loadedTiles = {},
tileZoom = 16,
oauth = osmAuth({
url: 'http://www.openstreetmap.org',
url: protocol + '//www.openstreetmap.org',
oauth_consumer_key: '5A043yRSEugj4DJ5TljuapfnrflWDte8jTOcWLlT',
oauth_secret: 'aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL',
loading: authenticating,

View File

@@ -2,13 +2,25 @@ describe('iD.Connection', function () {
var c;
beforeEach(function () {
c = new iD.Connection({});
c = new iD.Connection();
});
it('is instantiated', function () {
expect(c).to.be.ok;
});
it('allows insecure connections', function () {
expect(c.changesetURL(2)).to.match(/^http:/);
c = new iD.Connection(false);
expect(c.changesetURL(2)).to.match(/^http:/);
});
it('allows secure connections', function () {
c = new iD.Connection(true);
expect(c.changesetURL(2)).to.match(/^https:/);
});
describe('#changesetUrl', function() {
it('provides a changeset url', function() {
expect(c.changesetURL(2)).to.eql('http://www.openstreetmap.org/changeset/2');