Skip to main content

encode_uri_fragment

Function encode_uri_fragment 

Source
pub fn encode_uri_fragment(fragment: &str) -> String
Expand description

JavaScript’s encodeURI, with # also encoded, for a fragment. URI structure characters (/ ? : @ & = + $ ; ,) are kept, so a fragment such as page=2 reads back as written.

§Examples

use markdown_link::encode_uri_fragment;

assert_eq!(encode_uri_fragment("page=2"), "page=2");
assert_eq!(encode_uri_fragment("A heading #2"), "A%20heading%20%232");