Skip to content

[extra::url] Support URL with non-relative schemes #10705

Closed
@SimonSapin

Description

@SimonSapin

The current implementation of the Url struct looks like this:

pub struct Url {
    scheme: ~str,
    user: Option<UserInfo>,
    host: ~str,
    port: Option<~str>,
    path: ~str,
    query: Query,
    fragment: Option<~str>
}

It always has user, host, port, path and query fields, but those only exist for URLs with a relative scheme such as mailto or data. The data structure should be something like this:

pub struct Url {
    scheme: ~str,
    scheme_data: SchemeData,
    fragment: Option<~str>
}

pub enum SchemeData {
    RelativeSchemeData(RelativeSchemeData),
    OtherSchemeData(~str),
}

pub struct RelativeSchemeData {
    user: Option<UserInfo>,
    host: ~str,
    port: Option<~str>,
    path: ~str,
    query: Query,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions