feat(bundler) add exception_domain option by nothingismagick (#439)

This commit is contained in:
Lucas Fernandes Nogueira 2020-02-19 16:07:50 -03:00 committed by GitHub
parent c1638e92a6
commit 12ed096bea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -214,6 +214,27 @@ fn create_info_plist(
copyright
)?;
}
if let Some(exception_domain) = settings.exception_domain() {
write!(
file,
" <key>NSAppTransportSecurity</key>\n \
<dict>\n \
<key>NSExceptionDomains</key>\n \
<dict>\n \
<key>{}</key>\n \
<dict>\n \
<key>NSExceptionAllowsInsecureHTTPLoads</key>\n \
<true/>\n \
<key>NSIncludesSubdomains</key>\n \
<true/>\n \
</dict>\n \
</dict>\n \
</dict>",
exception_domain
)?;
}
write!(file, "</dict>\n</plist>\n")?;
file.flush()?;
Ok(())

View File

@ -111,6 +111,7 @@ struct BundleSettings {
bin: Option<HashMap<String, BundleSettings>>,
example: Option<HashMap<String, BundleSettings>>,
external_bin: Option<Vec<String>>,
exception_domain: Option<String>,
}
#[derive(Clone, Debug, Deserialize)]
@ -433,6 +434,10 @@ impl Settings {
}
}
pub fn exception_domain(&self) -> Option<&String> {
return self.bundle_settings.exception_domain.as_ref()
}
// copy external binaries to a path.
pub fn copy_binaries(&self, path: &Path) -> crate::Result<()> {
for src in self.external_binaries() {