Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith-prefix

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-prefix - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

26

lib/index.js

@@ -81,4 +81,12 @@

function addPrefix (str, prefix) {
var url = parse(str)
/**
* Add prefix to URL
*
* @param {String} input
* @param {String} prefix
* @return {String}
*/
function addPrefix (input, prefix) {
var url = parse(input)
url.pathname = '/' + prefix + url.pathname

@@ -88,2 +96,9 @@ return format(url)

/**
* Get URL attribute to rewrite from an element
*
* @param {Object} el
* @return {String}
*/
function getAttribute (el) {

@@ -95,2 +110,9 @@ return (typeof map[el.name] !== 'undefined')

/**
* Check if URL is absolute
*
* @param {String} url
* @return {Boolean}
*/
function isAbsolute (url) {

@@ -97,0 +119,0 @@ return url.indexOf('/') === 0 &&

{
"name": "metalsmith-prefix",
"version": "1.0.0",
"version": "1.0.1",
"description": "A metalsmith plugin to prefix internal URLs",

@@ -14,5 +14,13 @@ "main": "index.js",

},
"files": [
"lib/index.js"
],
"scripts": {
"test": "make test"
},
"keywords": [
"metalsmith",
"url",
"prefix"
],
"repository": {

@@ -19,0 +27,0 @@ "type": "git",

@@ -5,4 +5,18 @@ # metalsmith-prefix

It rewrites all absolute internal URLs to use this prefix. So references to `http://example.com` or `path/to/url` wouldn't be rewritten, but `/path/to/url` would.
It rewrites all absolute internal URLs to use this prefix, but no external or relative ones. So the rendered html
```html
<a href="http://example.com"></a>
<a href="path/to/url"></a>
<a href="/path/to/url"></a>
```
Would become this when prefixed with 'prefix'
```html
<a href="http://example.com"></a>
<a href="path/to/url"></a>
<a href="/prefix/path/to/url"></a>
```
## Installation

@@ -9,0 +23,0 @@

.npmignore
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