Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sm/label-encoding-test #1102

Merged
merged 2 commits into from
Sep 6, 2023
Merged
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 src/convert/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export class JsToXml extends Readable {
indentBy: ' ',
ignoreAttributes: false,
cdataPropName: '__cdata',
processEntities: false,
});

const builtXml = String(builder.build(this.xmlObject));
Expand Down
23 changes: 23 additions & 0 deletions test/convert/streams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,29 @@ describe('Streams', () => {
expect(jsToXml.read().toString()).to.be.equal(expectedBody);
});

it('should transform js with html encoding to xml', () => {
const xmlObj = {
TestType: {
[XML_NS_KEY]: XML_NS_URL,
foo: '3 results, and 1 other',
many: [{ test: 'first&#1601st' }, { test: 'second&#1602nd' }],
},
};
const jsToXml = new streams.JsToXml(xmlObj);
let expectedBody = XML_DECL;
expectedBody += `<TestType xmlns="${XML_NS_URL}">\n`;
expectedBody += ' <foo>3 results,&#160;and 1 other</foo>\n';
expectedBody += ' <many>\n';
expectedBody += ' <test>first&#1601st</test>\n';
expectedBody += ' </many>\n';
expectedBody += ' <many>\n';
expectedBody += ' <test>second&#1602nd</test>\n';
expectedBody += ' </many>\n';
expectedBody += '</TestType>\n';

expect(jsToXml.read().toString()).to.be.equal(expectedBody);
});

it('should transform js object with cdata to xml string', () => {
const xmlObj = {
TestType: {
Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4821,14 +4821,7 @@ semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.3.4, semver@^7.3.7, semver@^7.5.0, semver@^7.5.1:
version "7.5.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.1.tgz#c90c4d631cf74720e46b21c1d37ea07edfab91ec"
integrity sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==
dependencies:
lru-cache "^6.0.0"

semver@^7.5.4:
semver@^7.3.4, semver@^7.3.7, semver@^7.5.0, semver@^7.5.1, semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
Expand Down
Loading