Absolutify
Replace relative URLs with absolute in a given HTML string.
Install / Use
/learn @sorensen/AbsolutifyREADME
Absolutify
Replace relative URLs in a string with absolute URLs. This library is extremely small and lightweight, and requires no external dependencies.
The primary motivation of this library is to be concise and performant, when
searching for this functionality, the common solution is to use actual DOM
manipulation for finding and replacing URLs, using jQuery, cheerio, and/or jsdom.
Install
npm install absolutify
Usage
var absolutify = require('absolutify')
var html = '<html><a href="/sorensen">Home</a></html>'
var site = 'https://github.com'
var parsed = absolutify(html, site)
// '<html><a href="https://github.com/sorensen">Home</a></html>'
var byFunction = absolutify(html, function(url, attrName) {
// url === '/sorensen'
// attr === 'href'
return site + url
})
Supported Attributes
This library searches a given HTML string for the following attribute values that
start with either / or any form of ../ pathing.
| Attribute | | ---------- | | href | | src | | codebase | | cite | | background | | action | | profile | | formaction | | icon | | manifest | | archive |
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。



