Skip to content

Commit

Permalink
Merge pull request #21 from diogoriba/master
Browse files Browse the repository at this point in the history
adding flags for compatibility w/ full https websites
  • Loading branch information
Urigo committed Nov 30, 2014
2 parents da5bb4e + ecf4da9 commit 9cdb314
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
15 changes: 13 additions & 2 deletions angular-embedly.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,29 @@ var angularEmbedly = angular.module('angular-embedly', []);
(function (module) {
module.provider('embedlyService', function () {
var key;
var secure;
this.setKey = function(userKey) {
key = userKey;
return key;
}
this.getKey = function() {
return key;
}
this.secure = function(value) {
if (!value) {
return secure;
}
secure = value;
}

function getProtocol() {
return secure ? 'https' : 'https' ;
}

function embedly($http) {
this.embed = function(inputUrl, maxwidth) {
var escapedUrl = encodeURI(inputUrl);
var embedlyRequest = 'http://api.embed.ly/1/oembed?key=' + key + '&url=' + escapedUrl;
var embedlyRequest = getProtocol() + '://api.embed.ly/1/oembed?key=' + key + '&url=' + escapedUrl;

if(typeof maxwidth !== 'undefined'){
embedlyRequest = embedlyRequest + '&maxwidth=' + maxwidth;
Expand All @@ -31,7 +42,7 @@ var angularEmbedly = angular.module('angular-embedly', []);
};
this.extract = function(inputUrl) {
var escapedUrl = encodeURI(inputUrl);
var embedlyRequest = 'http://api.embed.ly/1/extract?key=' + key + '&url=' + escapedUrl;
var embedlyRequest = getProtocol + '://api.embed.ly/1/extract?key=' + key + '&url=' + escapedUrl;
return $http({method: 'GET', url: embedlyRequest});
};
}
Expand Down
2 changes: 1 addition & 1 deletion em-minified/angular-embedly.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/services/embedlyService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,29 @@
(function (module) {
module.provider('embedlyService', function () {
var key;
var secure;
this.setKey = function(userKey) {
key = userKey;
return key;
}
this.getKey = function() {
return key;
}
this.secure = function(value) {
if (!value) {
return secure;
}
secure = value;
}

function getProtocol() {
return secure ? 'https' : 'https' ;
}

function embedly($http) {
this.embed = function(inputUrl, maxwidth) {
var escapedUrl = encodeURI(inputUrl);
var embedlyRequest = 'http://api.embed.ly/1/oembed?key=' + key + '&url=' + escapedUrl;
var embedlyRequest = getProtocol() + '://api.embed.ly/1/oembed?key=' + key + '&url=' + escapedUrl;

if(typeof maxwidth !== 'undefined'){
embedlyRequest = embedlyRequest + '&maxwidth=' + maxwidth;
Expand All @@ -26,7 +37,7 @@
};
this.extract = function(inputUrl) {
var escapedUrl = encodeURI(inputUrl);
var embedlyRequest = 'http://api.embed.ly/1/extract?key=' + key + '&url=' + escapedUrl;
var embedlyRequest = getProtocol + '://api.embed.ly/1/extract?key=' + key + '&url=' + escapedUrl;
return $http({method: 'GET', url: embedlyRequest});
};
}
Expand Down

0 comments on commit 9cdb314

Please sign in to comment.