Skip to content

raku-community-modules/PostCocoon-Url

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Actions Status Actions Status Actions Status

NAME

PostCocoon::Url - Some simple but useful URL utils

SYNOPSIS

use PostCocoon::Url;

say url-encode("👌");           # %F0%9F%91%8C
say url-decode("%F0%9F%91%8C"); # 👌

DESCRIPTION

A collection of functions that can be used for URL parsing, building and changing.

Also provides an loose URL tokenizer

sub url-encode

sub url-encode(
    Str:D $data
) returns Str:D

Transforms a string into a percent encoded string

sub url-decode

sub url-decode(
    Str:D $data
) returns Str:D

Transforms a percent encoded string into a plain string

multi sub build-query-string

multi sub build-query-string(
    Hash:D $hash
) returns Str:D

Build a query string from a Hash

multi sub build-query-string

multi sub build-query-string(
    *%hash
) returns Str:D

Build a query string from the named arguments

sub parse-query-string

sub parse-query-string(
    Str:D $query-string
) returns Hash

Parse a query string

class PostCocoon::Url::URL-Parser

Loose URL parser that doesn't follow RFC3986 not completely

sub is-valid-url

sub is-valid-url(
    Str $uri
) returns Bool

Check if something is a valid URL according to the parser

sub parse-url

sub parse-url(
    Str $uri
) returns Hash

Return a hash with all items of the URL

multi sub build-url

multi sub build-url(
    Hash:D $hash
) returns Str:D

Build a URL from a given hash, this function does no error checking at all, it may result in an invalid URL

multi sub build-url

multi sub build-url(
    *%hash
) returns Str

Build an url from given named parameters, this function does no error checking at all, it may result in an invalid url

AUTHOR

eater

COPYRIGHT AND LICENSE

Copyright 2017 eater

Copyright 2024 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

Packages

No packages published

Languages

  • Raku 100.0%