1.1.0 • Published 9 months ago

als-url-fixer v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

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.