Skip to content

Commit

Permalink
De-duplicate url parser percent encoding constants with those defined…
Browse files Browse the repository at this point in the history
… in percent_encoding.
  • Loading branch information
cryptoquick authored and lucacasonato committed Jul 12, 2023
1 parent a3785bc commit 7cf28a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub use form_urlencoded;
extern crate serde;

use crate::host::HostInternal;
use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT, USERINFO};
use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode};
use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT};
use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode, USERINFO};
use std::borrow::Borrow;
use std::cmp;
use std::fmt::{self, Write};
Expand Down
23 changes: 3 additions & 20 deletions url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,9 @@ use std::str;
use crate::host::{Host, HostInternal};
use crate::Url;
use form_urlencoded::EncodingOverride;
use percent_encoding::{percent_encode, utf8_percent_encode, AsciiSet, CONTROLS};

/// https://url.spec.whatwg.org/#fragment-percent-encode-set
const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');

/// https://url.spec.whatwg.org/#path-percent-encode-set
const PATH: &AsciiSet = &FRAGMENT.add(b'#').add(b'?').add(b'{').add(b'}');

/// https://url.spec.whatwg.org/#userinfo-percent-encode-set
pub(crate) const USERINFO: &AsciiSet = &PATH
.add(b'/')
.add(b':')
.add(b';')
.add(b'=')
.add(b'@')
.add(b'[')
.add(b'\\')
.add(b']')
.add(b'^')
.add(b'|');
use percent_encoding::{
percent_encode, utf8_percent_encode, AsciiSet, CONTROLS, FRAGMENT, PATH, USERINFO,
};

pub(crate) const PATH_SEGMENT: &AsciiSet = &PATH.add(b'/').add(b'%');

Expand Down

0 comments on commit 7cf28a9

Please sign in to comment.