als-url-fixer

1.1.0 • Public • Published

als-url-fixer

A utility to sanitize, validate, and refine URLs for consistent and safe usage.

Introduction

Web applications often require processing, validating, and sanitizing URLs to ensure they're accurate and safe to use. als-url-fixer is a lightweight and comprehensive utility designed to provide a seamless approach to handling URLs.

Installation

To install als-url-fixer, use npm:

npm install als-url-fixer

Usage

Basic Usage

const fixUrl = require('als-url-fixer');

const sanitizedUrl = fixUrl('http://www.example.com');
console.log(sanitizedUrl); // Expected output: 'http://www.example.com/'

Using with Referer

const referer = 'https://some-referer.com/super/puper/shmuper';
const relativeUrl = '/relative/path';

const resolvedUrl = fixUrl(relativeUrl, referer);
console.log(resolvedUrl); // Expected output: 'https://some-referer.com/relative/path'

For more examples, check the test folder in the source repository.

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i als-url-fixer

    Weekly Downloads

    3

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    8.57 kB

    Total Files

    4

    Last publish

    Collaborators

    • alexsorkin