@unitio-code/url-shortener
Version:
A simple URL shortening library
23 lines (22 loc) • 884 B
TypeScript
import { ShortUrlOptions } from "./utils";
/**
* Options for creating a short URL
*/
export interface CreateShortUrlOptions extends ShortUrlOptions {
hashAlgorithm?: "djb2" | "sdbm" | "custom";
customHashFn?: (url: string) => number;
}
/**
* Creates a short URL from a long URL with customizable options
* @param longUrl - The original long URL to shorten
* @param domain - Domain name for the short URL
* @param options - Optional configuration options
* @returns The shortened URL
*/
export declare function createShortUrl(longUrl: string, domain: string, options?: Partial<Omit<CreateShortUrlOptions, "domain">>): string;
/**
* Decodes a short URL back to its original URL
* @param shortUrl - The shortened URL to decode
* @returns The original URL if found, or undefined if not found
*/
export declare function decodeUrl(shortUrl: string): string | undefined;