Skip to content

Commit

Permalink
Merge pull request #1055 from tlemburg/events-widget-https-fix
Browse files Browse the repository at this point in the history
Force events widgets to use https to retrieve events
  • Loading branch information
mfairchild365 committed Mar 7, 2017
2 parents 2bde94c + 8e51e22 commit 9dae8df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion wdn/templates_4.1/scripts/events-band.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define([
},

container = '#events-band',
defaultCal = '//events.unl.edu/';
defaultCal = 'https://events.unl.edu/';

var fetchEvents = function(localConfig) {
var upcoming = 'upcoming/',
Expand Down Expand Up @@ -94,6 +94,13 @@ define([
},
localConfig = $.extend({}, defaultConfig, config);

// ensure that the URL we are about to use is forced into an https:// protocol. (add https if it starts with //)
if (localConfig.url && localConfig.url.match(/^\/\//)) {
localConfig.url = 'https:' + localConfig.url;
} else if (localConfig.url && localConfig.url.match(/^http:\/\//)) {
localConfig.url = localConfig.url.replace('http://', 'https://');
}

if (localConfig.url && $(localConfig.container).length) {
fetchEvents(localConfig);
}
Expand Down
9 changes: 8 additions & 1 deletion wdn/templates_4.1/scripts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define([
return eventParams || {};
},
container = '#wdn_calendarDisplay',
defaultCal = '//events.unl.edu/';
defaultCal = 'https://events.unl.edu/';

var display = function(data, config) {
var $container = $(config.container).addClass('wdn-calendar');
Expand Down Expand Up @@ -97,6 +97,13 @@ define([
},
localConfig = $.extend({}, defaultConfig, config);

// ensure that the URL we are about to use is forced into an https:// protocol. (add https if it starts with //)
if (localConfig.url && localConfig.url.match(/^\/\//)) {
localConfig.url = 'https:' + localConfig.url;
} else if (localConfig.url && localConfig.url.match(/^http:\/\//)) {
localConfig.url = localConfig.url.replace('http://', 'https://');
}

if (localConfig.url && $(localConfig.container).length) {
$(this.container).addClass('wdn-calendar');
$.getJSON(localConfig.url + 'upcoming/?format=json&limit=' + encodeURIComponent(localConfig.limit), function(data) {
Expand Down
9 changes: 8 additions & 1 deletion wdn/templates_4.1/scripts/monthwidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define([
return eventParams || {};
},
container = '#monthwidget',
defaultCal = '//events.unl.edu/';
defaultCal = 'https://events.unl.edu/';

var display = function(data, config) {
var $container = $(config.container);
Expand Down Expand Up @@ -109,6 +109,13 @@ define([
},
localConfig = $.extend({}, defaultConfig, config);

// ensure that the URL we are about to use is forced into an https:// protocol. (add https if it starts with //)
if (localConfig.url && localConfig.url.match(/^\/\//)) {
localConfig.url = 'https:' + localConfig.url;
} else if (localConfig.url && localConfig.url.match(/^http:\/\//)) {
localConfig.url = localConfig.url.replace('http://', 'https://');
}

if (localConfig.url && $(localConfig.container).length) {
$.get(localConfig.url + '?monthwidget&format=hcalendar', function(data) {
display(data, localConfig);
Expand Down

0 comments on commit 9dae8df

Please sign in to comment.