Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

fix(codepen): escape ampersand in   #2827

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/app/js/codepen.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
function htmlEscapeAmpersand(html) {
return html
.replace(/>/g, ">")
.replace(/ /g, " ")
.replace(/</g, "<");
}

Expand Down
9 changes: 9 additions & 0 deletions docs/spec/codepen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ describe('CodepenDataAdapter', function() {

});

describe('when the html example includes  ', function() {

it('escapes the ampersand, so that the codepen does not translate to an invalid character', function() {
demo.files.index.contents = '<div>&nbsp;&nbsp;</div>';
data = codepenDataAdapter.translate(demo, externalScripts);
expect(angular.element(data.html).html()).toBe('&amp;nbsp;&amp;nbsp;');
});
});

describe('when the module definition in the js file is formatted in different ways', function() {

it('handles second argument on a new line', function() {
Expand Down