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

@docusaurus/utils

Package Overview
Dependencies
Maintainers
3
Versions
1839
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/utils - npm Package Compare versions

Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7

4

package.json
{
"name": "@docusaurus/utils",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "Node utility functions for Docusaurus packages",

@@ -16,3 +16,3 @@ "main": "src/index.js",

},
"gitHead": "d097f73285d275ce9fc19d40801f02a5c913b616"
"gitHead": "1ce4195f1498b966df4f3d3e823bf386fd9ba424"
}

@@ -36,3 +36,3 @@ /**

const asserts = {
'/': 'Index',
'/': 'index',
'/foo-bar': 'FooBar096',

@@ -55,3 +55,3 @@ '/foo/bar': 'FooBar1Df',

'': '-d41',
'/': 'Index',
'/': 'index',
'/foo-bar': 'foo-bar-096',

@@ -86,3 +86,3 @@ '/foo/bar': 'foo-bar-1df',

test('genChunkName', () => {
const asserts = {
let asserts = {
'/docs/adding-blog': 'docs-adding-blog-062',

@@ -100,2 +100,16 @@ '/docs/versioning': 'docs-versioning-8a8',

});
// Don't allow different chunk name for same path.
expect(genChunkName('path/is/similar', 'oldPrefix')).toEqual(
genChunkName('path/is/similar', 'newPrefix'),
);
// Even with same preferred name, still different chunk name for different path
asserts = {
'/blog/1': 'blog-85-f-089',
'/blog/2': 'blog-353-489',
};
Object.keys(asserts).forEach(str => {
expect(genChunkName(str, undefined, 'blog')).toBe(asserts[str]);
});
});

@@ -102,0 +116,0 @@

@@ -50,3 +50,3 @@ /**

if (str === '/') {
return 'Index';
return 'index';
}

@@ -67,3 +67,3 @@ const shortHash = createHash('md5')

if (pagePath === '/') {
return 'Index';
return 'index';
}

@@ -93,5 +93,19 @@ const pageHash = docuHash(pagePath);

function genChunkName(str, prefix) {
const name = str === '/' ? 'index' : docuHash(str);
return prefix ? `${prefix}---${name}` : name;
const chunkNameCache = new Map();
function genChunkName(modulePath, prefix, preferredName) {
let chunkName = chunkNameCache.get(modulePath);
if (!chunkName) {
let str = modulePath;
if (preferredName) {
const shortHash = createHash('md5')
.update(modulePath)
.digest('hex')
.substr(0, 3);
str = `${preferredName}${shortHash}`;
}
const name = str === '/' ? 'index' : docuHash(str);
chunkName = prefix ? `${prefix}---${name}` : name;
chunkNameCache.set(modulePath, chunkName);
}
return chunkName;
}

@@ -98,0 +112,0 @@

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