Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-09-05 15:50:29 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-05 15:50:29 +0400
commitc33d0394cf723599d63f9eddbb727c3e57cc5a84 (patch)
treee641069aeb4dbd8f15700ffaad81149126dd22fe /js
parent96ed663d643b55b2f6fa86777d58e25e53eb3fce (diff)
refs #4996 and even more tests and more bugfixes
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js51
1 files changed, 33 insertions, 18 deletions
diff --git a/js/piwik.js b/js/piwik.js
index 9ae51a4b9a..4d801a5003 100644
--- a/js/piwik.js
+++ b/js/piwik.js
@@ -1484,6 +1484,10 @@ if (typeof Piwik !== 'object') {
},
findContentName: function (node)
{
+ if (!node) {
+ return;
+ }
+
var nameNode = query.findFirstNodeHavingAttributeWithValue(node, this.CONTENT_NAME_ATTR);
if (nameNode) {
@@ -1492,7 +1496,7 @@ if (typeof Piwik !== 'object') {
var contentPiece = this.findContentPiece(node);
if (contentPiece) {
- return this.removeDomainIfIsUrl(contentPiece);
+ return this.removeDomainIfIsInLink(contentPiece);
}
if (query.hasNodeAttributeWithValue(node, 'title')) {
@@ -1513,6 +1517,10 @@ if (typeof Piwik !== 'object') {
},
findContentPiece: function (node)
{
+ if (!node) {
+ return;
+ }
+
var nameNode = query.findFirstNodeHavingAttributeWithValue(node, this.CONTENT_PIECE_ATTR);
if (nameNode) {
@@ -1525,22 +1533,13 @@ if (typeof Piwik !== 'object') {
if (media) {
return media;
}
-
- var targetNode = this.findTargetNode(node);
-
- if (contentNode !== targetNode) {
- var media = this.findMediaUrlInNode(targetNode);
- if (media) {
- return media;
- }
- }
-
- // contentNode.innerText
-
- return '';
},
findContentTarget: function (node)
{
+ if (!node) {
+ return;
+ }
+
var targetNode = this.findTargetNode(node);
if (query.hasNodeAttributeWithValue(targetNode, this.CONTENT_TARGET_ATTR)) {
@@ -1560,12 +1559,28 @@ if (typeof Piwik !== 'object') {
return this.toAbsoluteUrl(href);
}
},
- removeDomainIfIsUrl: function (text) {
- // we will only remove if domain is !== location.origin meaning an outlink
+ isSameDomain: function (url) {
+ if (!url || !url.indexOf) {
+ return false;
+ }
+
+ if (0 === url.indexOf(this.getLocation().origin)) {
+ return true;
+ }
+
+ var posHost = url.indexOf(this.getLocation().host);
+ if (8 >= posHost && 0 <= posHost) {
+ return true;
+ }
+
+ return false;
+ },
+ removeDomainIfIsInLink: function (text) {
+ // we will only remove if domain === location.origin meaning is not an outlink
if (text &&
text.search &&
- -1 !== text.search(/^https?:\/\/[^\/]+/) &&
- 0 !== text.indexOf(window.location.origin)) {
+ -1 !== text.search(/^https?:\/\/[^\/]+/)
+ && this.isSameDomain(text)) {
text = text.replace(/^.*\/\/[^\/]+/, '');
if (!text) {