mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 23:53:24 +02:00
Remove only trailing slashes (#3183)
This commit is contained in:
@@ -70,6 +70,12 @@ describe('Path Utilities', () => {
|
|||||||
.toBe('/home/user/some path');
|
.toBe('/home/user/some path');
|
||||||
expect(normalizePath('"/usr/local/some app/"'))
|
expect(normalizePath('"/usr/local/some app/"'))
|
||||||
.toBe('/usr/local/some app');
|
.toBe('/usr/local/some app');
|
||||||
|
expect(normalizePath('/usr/local//bin/app///'))
|
||||||
|
.toBe('/usr/local/bin/app');
|
||||||
|
expect(normalizePath('/'))
|
||||||
|
.toBe('/');
|
||||||
|
expect(normalizePath('///'))
|
||||||
|
.toBe('/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes surrounding quotes', () => {
|
it('removes surrounding quotes', () => {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function normalizePath(p: string): string {
|
|||||||
if (isUnixPath) {
|
if (isUnixPath) {
|
||||||
// For Unix paths, just normalize without converting to Windows format
|
// For Unix paths, just normalize without converting to Windows format
|
||||||
// Replace double slashes with single slashes and remove trailing slashes
|
// Replace double slashes with single slashes and remove trailing slashes
|
||||||
return p.replace(/\/+/g, '/').replace(/\/+$/, '');
|
return p.replace(/\/+/g, '/').replace(/(?<!^)\/$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert Unix-style Windows paths (/c/, /d/) to Windows format if on Windows
|
// Convert Unix-style Windows paths (/c/, /d/) to Windows format if on Windows
|
||||||
|
|||||||
Reference in New Issue
Block a user