This library is designed to expand short URLs for Node.JS
npm install expand-short-url
This library is designed to expand short URLs. This does not have any external dependencies and is lightweight.
``sh`
npm install expand-short-urls
`typescript
import { expand } from 'expand-short-url';
const shortURL = 'https://bit.ly/3xYz1a2';
const expandedURL = await expand(shortURL);
console.log(expandedURL);
`
You can pass options to the expand function to customize its behavior. Also, you can pass any options supported by http.request or https.request module.
1. timeout: The maximum time to wait for the expansion to complete (default: 5000 ms).maxRedirects
2. : The maximum number of redirects to follow (default: 3).
`typescript`
import { expand } from 'expand-short-url';
const shortURL = 'https://bit.ly/3xYz1a2';
const expandedURL = await expand(shortURL, { timeout: 10000, maxRedirects: 5 });
console.log(expandedURL);
`javascript``
'https://example.com/'
If you like my work, please consider giving it a star on GitHub or
Sponsor my work by following sponsoring me link.