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

@docusaurus/utils-common

Package Overview
Dependencies
Maintainers
6
Versions
1463
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/utils-common - npm Package Compare versions

Comparing version 2.0.0-beta.af3640dca to 2.0.0-beta.b54ec7238

11

lib/applyTrailingSlash.js

@@ -10,4 +10,4 @@ "use strict";

function applyTrailingSlash(path, trailingSlash) {
// Never apply trailing slash to an anchor link
if (path.startsWith('#')) {
// Never apply trailing slash to an anchor link
return path;

@@ -28,7 +28,10 @@ }

const [pathname] = path.split(/[#?]/);
const newPathname = trailingSlash
? addTrailingSlash(pathname)
: removeTrailingSlash(pathname);
// Never transform '/' to ''
const newPathname = pathname === '/'
? '/'
: trailingSlash
? addTrailingSlash(pathname)
: removeTrailingSlash(pathname);
return path.replace(pathname, newPathname);
}
exports.default = applyTrailingSlash;
{
"name": "@docusaurus/utils-common",
"version": "2.0.0-beta.af3640dca",
"version": "2.0.0-beta.b54ec7238",
"description": "Common (Node/Browser) utility functions for Docusaurus packages.",

@@ -21,3 +21,3 @@ "main": "./lib/index.js",

"dependencies": {
"@docusaurus/types": "2.0.0-beta.af3640dca",
"@docusaurus/types": "2.0.0-beta.b54ec7238",
"tslib": "^2.2.0"

@@ -28,3 +28,3 @@ },

},
"gitHead": "6c6cc9296c98af43245cad38053d6703e700c610"
"gitHead": "c6e8e4791a712d9af474ab03453e50a035dd0757"
}

@@ -17,6 +17,16 @@ /**

test('should apply to /', () => {
test('should not apply to /', () => {
expect(applyTrailingSlash('/', true)).toEqual('/');
expect(applyTrailingSlash('/', false)).toEqual('');
expect(applyTrailingSlash('/', false)).toEqual('/');
expect(applyTrailingSlash('/', undefined)).toEqual('/');
expect(applyTrailingSlash('/?query#anchor', true)).toEqual(
'/?query#anchor',
);
expect(applyTrailingSlash('/?query#anchor', false)).toEqual(
'/?query#anchor',
);
expect(applyTrailingSlash('/?query#anchor', undefined)).toEqual(
'/?query#anchor',
);
});

@@ -23,0 +33,0 @@

Sorry, the diff of this file is not supported yet

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