0.2.3 • Published 4 years ago

@aicacia/location v0.2.3

Weekly downloads
1
License
(MIT OR Apache-2....
Repository
gitlab
Last release
4 years ago

ts-location

url location handling for browsers

import url = require("url");
import { createLocation } from "@aicacia/location";

const { parse } = url;

const handler = (url: url.UrlWithParsedQuery) =>
    url.pathname === "/not_allowed"
        ? // redirect to home, rejecting with null will ignore the request
          Promise.reject(parse("/", true))
        : Promise.resolve(url);

const location = createLocation(window, { html5Mode: true, handler });

// succuss
location.set("/allowed").then(() => {
    console.log("succuss");
});

// failure
location.set("/not_allowed").catch(error => {
    console.error(error);
});

// remove DOM listeners
location.remove();
0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

5 years ago