mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move UTF8 bytes handling into generic constructor.
Separate from Servo specific logic.
This commit is contained in:
parent
52b3226d54
commit
d3b8b6472b
2 changed files with 11 additions and 11 deletions
|
@ -63,9 +63,11 @@ impl HSTSList {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create an `HSTSList` from the contents of a JSON preload file.
|
||||
pub fn from_preload(preload_content: &str) -> Option<HSTSList> {
|
||||
decode(preload_content).ok()
|
||||
/// Create an `HSTSList` from the bytes of a JSON preload file.
|
||||
pub fn from_preload(preload_content: &[u8]) -> Option<HSTSList> {
|
||||
from_utf8(&preload_content)
|
||||
.ok()
|
||||
.and_then(|c| decode(c).ok())
|
||||
}
|
||||
|
||||
pub fn is_host_secure(&self, host: &str) -> bool {
|
||||
|
@ -113,11 +115,9 @@ impl HSTSList {
|
|||
}
|
||||
|
||||
pub fn preload_hsts_domains() -> Option<HSTSList> {
|
||||
read_resource_file("hsts_preload.json").ok().and_then(|bytes| {
|
||||
from_utf8(&bytes).ok().and_then(|hsts_preload_content| {
|
||||
HSTSList::from_preload(hsts_preload_content)
|
||||
})
|
||||
})
|
||||
read_resource_file("hsts_preload.json")
|
||||
.ok()
|
||||
.and_then(|bytes| HSTSList::from_preload(&bytes))
|
||||
}
|
||||
|
||||
pub fn secure_url(url: &Url) -> Url {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue