Skip to main content

Module 0x2::url

URL: standard Uniform Resource Locator string

use 0x1::ascii;

Struct Url

Standard Uniform Resource Locator (URL) string.

struct Url has copy, drop, store
Fields

Function new_unsafe

Create a Url, with no validation

public fun new_unsafe(url: ascii::String): url::Url
Implementation
public fun new_unsafe(url: String): Url {
    Url { url }
}

Function new_unsafe_from_bytes

Create a Url with no validation from bytes Note: this will abort if bytes is not valid ASCII

public fun new_unsafe_from_bytes(bytes: vector<u8>): url::Url
Implementation
public fun new_unsafe_from_bytes(bytes: vector<u8>): Url {
    let url = bytes.to_ascii_string();
    Url { url }
}

Function inner_url

Get inner URL

public fun inner_url(self: &url::Url): ascii::String
Implementation
public fun inner_url(self: &Url): String{
    self.url
}

Function update

Update the inner URL

public fun update(self: &mut url::Url, url: ascii::String)
Implementation
public fun update(self: &mut Url, url: String) {
    self.url = url;
}