Socket
Socket
Sign inDemoInstall

absolutify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absolutify

Relative to Absolute URL Replacer


Version published
Weekly downloads
438
decreased by-25.64%
Maintainers
1
Weekly downloads
 
Created
Source

Absolutify

Build Status devDependency Status NPM version

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

License

Keywords

FAQs

Package last updated on 02 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc