Skip to content

Commit

Permalink
Core: Fix *.svg image support
Browse files Browse the repository at this point in the history
Fixes #57
  • Loading branch information
tabalinas committed Sep 14, 2016
1 parent dd15a7d commit 40b7eb3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/jssocials.js
Expand Up @@ -10,7 +10,7 @@
return value;
};

var IMG_SRC_REGEX = /(\.(jpeg|png|gif|bmp|svg\+xml)$|^data:image\/(jpeg|png|gif|bmp|svg\+xml);base64)/i;
var IMG_SRC_REGEX = /(\.(jpeg|png|gif|bmp|svg)$|^data:image\/(jpeg|png|gif|bmp|svg\+xml);base64)/i;
var URL_PARAMS_REGEX = /(&?[a-zA-Z0-9]+=)?\{([a-zA-Z0-9]+)\}/g;

var MEASURES = {
Expand Down
2 changes: 1 addition & 1 deletion src/jssocials.shares.js
Expand Up @@ -109,7 +109,7 @@
label: "Pocket",
logo: "fa fa-get-pocket",
shareUrl: "https://getpocket.com/save?url={url}&title={title}",
countUrl: "",
countUrl: ""
},

messenger: {
Expand Down
17 changes: 17 additions & 0 deletions test/jssocials.tests.js
Expand Up @@ -277,6 +277,23 @@
assert.equal($shareLogo.attr("src"), imgBase64, "img has base64 src");
});

QUnit.test("logo as svg image", function(assert) {
jsSocials.shares.testshare = {
shareUrl: "http://test.com/share"
};

var $element = $("#share").jsSocials({
shares: [{
share: "testshare",
logo: "test.svg"
}]
});

var $shareLogo = $element.find(".jssocials-share-logo");
assert.equal($shareLogo.get(0).tagName, "IMG", "<img> tag is rendered");
assert.equal($shareLogo.attr("src"), "test.svg", "img has svg image path");
});

QUnit.test("share should get sharing url and text", function(assert) {
jsSocials.shares.testshare = {
shareUrl: "http://test.com/share/?url={url}&text={text}"
Expand Down

0 comments on commit 40b7eb3

Please sign in to comment.