Skip to content

Commit

Permalink
fix(detox): use improved xml generation (#47)
Browse files Browse the repository at this point in the history
* fix xml generation

generate xml without space or new line in the beginning

* remove indentation

* update snapshots to no indentation

* add built file

Co-authored-by: Maurice Döpke <mauricedoepkeoutlook.de>
  • Loading branch information
mauricedoepke authored Mar 16, 2022
1 parent 480ec19 commit 6324eb0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
15 changes: 9 additions & 6 deletions packages/detox/build/withNetworkSecurityConfig.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`getTemplateFile returns domain-config when subdomains is an array 1`] = `
"
<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<network-security-config>
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<network-security-config>
<domain-config cleartextTrafficPermitted=\\"true\\">
<domain includeSubdomains=\\"true\\">localhost</domain>
</domain-config>
</network-security-config>
"
</network-security-config>"
`;
exports[`getTemplateFile returns only base-config when subdomains is '*' 1`] = `
"
<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<network-security-config>
<base-config cleartextTrafficPermitted=\\"true\\" />
</network-security-config>
"
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<network-security-config>
<base-config cleartextTrafficPermitted=\\"true\\" />
</network-security-config>"
`;

exports[`withNetworkSecurityConfigManifest doesn't modify config if subdomains is an empty array 1`] = `
Expand Down
15 changes: 9 additions & 6 deletions packages/detox/src/withNetworkSecurityConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ function getTemplateConfigContent(subdomains: SubdomainsType) {

export function getTemplateFile(subdomains: SubdomainsType): string {
const content = getTemplateConfigContent(subdomains);
return `
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
${content}
</network-security-config>
`;
/**
* May not have new lines or spaces in the beginning.
* Otherwise build fails with:
* "AAPT: error: XML or text declaration not at start of entity"
*/
return `<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
${content}
</network-security-config>`;
}

/**
Expand Down

0 comments on commit 6324eb0

Please sign in to comment.