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

rev-path

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rev-path - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

23

index.js

@@ -1,18 +0,17 @@

'use strict';
const modifyFilename = require('modify-filename');
import modifyFilename from 'modify-filename';
module.exports = (pth, hash) => {
if (!(pth && hash)) {
throw new Error('`path` and `hash` required');
export function revPath(path, hash) {
if (!(path && hash)) {
throw new Error('`path` and `hash` are required');
}
return modifyFilename(pth, (filename, ext) => `${filename}-${hash}${ext}`);
};
return modifyFilename(path, (filename, fileExtension) => `${filename}-${hash}${fileExtension}`);
}
module.exports.revert = (pth, hash) => {
if (!(pth && hash)) {
throw new Error('`path` and `hash` required');
export function unrevPath(path, hash) {
if (!(path && hash)) {
throw new Error('`path` and `hash` are required');
}
return modifyFilename(pth, (filename, ext) => filename.replace(new RegExp(`-${hash}$`), '') + ext);
};
return modifyFilename(path, (filename, fileExtension) => filename.replace(new RegExp(`-${hash}$`), '') + fileExtension);
}
{
"name": "rev-path",
"version": "2.0.0",
"version": "3.0.0",
"description": "Create a revved file path",
"license": "MIT",
"repository": "sindresorhus/rev-path",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=4"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -33,8 +36,8 @@ "scripts": {

"dependencies": {
"modify-filename": "^1.0.0"
"modify-filename": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^3.15.0",
"xo": "^0.46.4"
}
}

@@ -1,17 +0,16 @@

# rev-path [![Build Status](https://travis-ci.org/sindresorhus/rev-path.svg?branch=master)](https://travis-ci.org/sindresorhus/rev-path)
# rev-path
> Create a [revved file path](http://blog.risingstack.com/automatic-cache-busting-for-your-css/)
## Install
```sh
npm install rev-path
```
$ npm install rev-path
```
## Usage
```js
const revPath = require('rev-path');
import {revPath, unrevPath} from 'rev-path';
const hash = 'bb9d8fe615'

@@ -26,14 +25,8 @@

// You can also revert an already hashed path
revPath.revert(path, hash);
unrevPath(path, hash);
//=> 'src/unicorn.png'
```
## Related
- [rev-file](https://github.com/sindresorhus/rev-file) - Get the revved file path of a file
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

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