Skip to content

Commit

Permalink
Merge pull request origo-map#1199 from origo-map/url-attribute-missin…
Browse files Browse the repository at this point in the history
…g-fix

Fix for when url attribute is missing
  • Loading branch information
johnnyblasta authored Mar 10, 2021
2 parents 2e2dac2 + c2e10fe commit de6ceb0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/getattributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function parseUrl(urlattr, feature, attribute, attributes, map) {
url = createUrl(attribute.urlPrefix, attribute.urlSuffix, replacer.replace(urlattr, attributes, null, map));
} else if (isUrl(attribute.url)) {
url = attribute.url;
} else return false;
} else return '';
const text = feature.get(attribute.name) || attribute.html || attribute.title || urlattr;
const aTargetTitle = replacer.replace(attribute.targetTitle, attributes) || url;
let aTarget = '_blank';
Expand Down Expand Up @@ -45,9 +45,11 @@ const getContent = {
if (attribute.url) {
if (attribute.splitter) {
const urlArr = feature.get(attribute.url).split(attribute.splitter);
urlArr.forEach((url) => {
val += `<p>${parseUrl(url, feature, attribute, attributes, map)}</p>`;
});
if (urlArr[0] !== '') {
urlArr.forEach((url) => {
val += `<p>${parseUrl(url, feature, attribute, attributes, map)}</p>`;
});
}
} else {
val = parseUrl(feature.get(attribute.url), feature, attribute, attributes, map);
}
Expand All @@ -62,9 +64,11 @@ const getContent = {
let val = '';
if (attribute.splitter) {
const urlArr = feature.get(attribute.url).split(attribute.splitter);
urlArr.forEach((url) => {
val += `<p>${parseUrl(url, feature, attribute, attributes, map)}</p>`;
});
if (urlArr[0] !== '') {
urlArr.forEach((url) => {
val += `<p>${parseUrl(url, feature, attribute, attributes, map)}</p>`;
});
}
} else {
val = parseUrl(feature.get(attribute.url), feature, attribute, attributes, map);
}
Expand Down

0 comments on commit de6ceb0

Please sign in to comment.