Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
737 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | const contentVer = require('../../package.json')['cache-version'].content
|
---|
| 4 | const hashToSegments = require('../util/hash-to-segments')
|
---|
| 5 | const path = require('path')
|
---|
| 6 | const ssri = require('ssri')
|
---|
| 7 |
|
---|
| 8 | // Current format of content file path:
|
---|
| 9 | //
|
---|
| 10 | // sha512-BaSE64Hex= ->
|
---|
| 11 | // ~/.my-cache/content-v2/sha512/ba/da/55deadbeefc0ffee
|
---|
| 12 | //
|
---|
| 13 | module.exports = contentPath
|
---|
| 14 |
|
---|
| 15 | function contentPath (cache, integrity) {
|
---|
| 16 | const sri = ssri.parse(integrity, { single: true })
|
---|
| 17 | // contentPath is the *strongest* algo given
|
---|
| 18 | return path.join(
|
---|
| 19 | contentDir(cache),
|
---|
| 20 | sri.algorithm,
|
---|
| 21 | ...hashToSegments(sri.hexDigest())
|
---|
| 22 | )
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | module.exports.contentDir = contentDir
|
---|
| 26 |
|
---|
| 27 | function contentDir (cache) {
|
---|
| 28 | return path.join(cache, `content-v${contentVer}`)
|
---|
| 29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.