Fix 'data:,'-uri attachement treatment
Change-Id: Icf92033fe24103271ba52a2dda65ea198fca25b2
diff --git a/dev/js/spec/matchSpec.js b/dev/js/spec/matchSpec.js
index 04e188e..9b3ef9e 100644
--- a/dev/js/spec/matchSpec.js
+++ b/dev/js/spec/matchSpec.js
@@ -86,7 +86,12 @@
"type": "type:attachement",
"value": "data:application/x.korap-link;title=Cool,https://de.wikipedia.org/wiki/Beispiel"
},
-
+ {
+ "@type": "koral:field",
+ "key": "z-reference",
+ "type": "type:attachement",
+ "value": "data:,This is a reference"
+ }
];
@@ -752,14 +757,20 @@
});
it('attachements should be formatted', function(){
- //type:attachement
+ //type:attachement with a link
expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement')
expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy;
expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink');
expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool');
expect(mel.children[3].children[1].firstChild.tagName).toEqual('A');
expect(mel.children[3].children[1].firstChild.getAttribute('href')).toEqual('https://de.wikipedia.org/wiki/Beispiel');
- });
+
+ //type:attachement with plain text
+ expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement')
+ expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy;
+ expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('z-reference');
+ expect(mel.children[4].children[1].firstChild.nodeValue).toEqual('This is a reference');
+ });
diff --git a/dev/js/src/match/attachement.js b/dev/js/src/match/attachement.js
index 4548703..7b6cb94 100644
--- a/dev/js/src/match/attachement.js
+++ b/dev/js/src/match/attachement.js
@@ -10,7 +10,7 @@
* @author Nils Diewald
*/
define(function () {
- const uriRE = new RegExp("^data: *([^;,]+?(?: *; *[^,;]+?)*) *, *(.+)$");
+ const uriRE = new RegExp("^data: *([^;,]*?(?: *; *[^,;]+?)*) *, *(.+)$");
const mapRE = new RegExp("^ *([^=]+?) *= *(.+?) *$");
return {