Skip to content

Commit

Permalink
[BUGFIX] Avoid error in Rich Result Test when validating JSON-LD via …
Browse files Browse the repository at this point in the history
…Admin Panel

Related: #71
  • Loading branch information
brotkrueml committed Aug 9, 2021
1 parent e5105a4 commit 129f43a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Avoid error in Rich Result Test when validating JSON-LD via Admin Panel

## [1.12.0] - 2021-07-07

### Updated
Expand Down
13 changes: 9 additions & 4 deletions Resources/Public/JavaScript/AdminPanel/Validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@

var invokeRichResultTest = function(event) {
event.preventDefault();
submitForm(options.tools.rtt.actionUrl, 'code_snippet');
submitForm('rtt', options.tools.rtt.actionUrl, 'code_snippet');
}

var invokeSchemaMarkupValidator = function(event) {
event.preventDefault();
submitForm(options.tools.smv.actionUrl, 'code');
submitForm('smv', options.tools.smv.actionUrl, 'code');
}

var submitForm = function(actionUrl, codeFieldName) {
var submitForm = function(type, actionUrl, codeFieldName) {
var code = JSON.stringify(jsonLdObject, null, '\t');
if (type === 'rtt') {
code = '<script type="application/ld+json">\n' + code + '\n</script>';
}

var form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', actionUrl);
Expand All @@ -56,7 +61,7 @@

var codeField = document.createElement('textarea');
codeField.setAttribute('name', codeFieldName);
codeField.textContent = JSON.stringify(jsonLdObject, null, '\t');
codeField.textContent = code;
form.appendChild(codeField);
document.body.appendChild(form);

Expand Down

0 comments on commit 129f43a

Please sign in to comment.