4.0.0 • Published 2 years ago

@zthun/works.url v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Description

A very small library that allows you to build a new url or parse an existing url to modify it.

Installation

# NPM
npm install @zthun/works.url
# Yarn
yarn add @zthun/works.url

Usage

import { ZUrlBuilder } from '@zthun/works.url';

function createUrls(): string[] {
  // Uses the current location and appends the base api path specified.  The default is
  // api.  Assume we are on https://zthunworks.com/#/home
  return [
    // Create urls from scratch
    // Outputs: ftp://zthunworks.com:3662/path/to/resource/?foo=bar&name=joe/#/home
    new ZUrlBuilder().protocol('ftp').host('zthunworks.com').path('/path/to').append('resource').port(3662).param('foo', 'bar').param('name', 'joe').hash('home').build(),

    // Create urls based on the current browser location.
    // Outputs: https://zthunworks.com/#/home
    new ZUrlBuilder().location().build(),

    // Creates urls based on the location and a base path for your server api
    // Outputs: https://zthunworks.com/api
    new ZUrlBuilder().api().build(),
    // Outputs: https://zthunworks.com/server
    new ZUrlBuilder().api(location, 'server').build(),

    // Parse existing urls and add subdomains to it.
    // https://coffee.zthunworks.com/#/login
    new ZUrlBuilder().parse('https://zthunworks.com/#/login').subdomain('coffee').build()
  ];
}
4.0.0

2 years ago

3.0.2

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

1.0.0-29

3 years ago

1.0.0-26

3 years ago

1.0.0-25

3 years ago

1.0.0-24

3 years ago

1.0.0-22

3 years ago

1.0.0-17

4 years ago

1.0.0-16

4 years ago

1.0.0-15

4 years ago

1.0.0-9

4 years ago