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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2966
Yes
13
32
+ Addedmodify-filename@2.0.0(transitive)
- Removedmodify-filename@1.1.0(transitive)
Updatedmodify-filename@^2.0.0