Function data_url::decode_without_base64

source ·
pub(crate) fn decode_without_base64<F, E>(
    encoded_body_plus_fragment: &str,
    write_bytes: F,
) -> Result<Option<FragmentIdentifier<'_>>, E>
where F: FnMut(&[u8]) -> Result<(), E>,
Expand description

This is https://url.spec.whatwg.org/#string-percent-decode while also:

  • Ignoring ASCII tab or newlines
  • Stopping at the first ‘#’ (which indicates the start of the fragment)

Anything that would have been UTF-8 percent-encoded by the URL parser would be percent-decoded here. We skip that round-trip and pass it through unchanged.