deno.land / std@0.224.0 / path / _common / strip_trailing_separators.ts
1234567891011121314151617181920212223242526// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// Copyright the Browserify authors. MIT License.// Ported from https://github.com/browserify/path-browserify/// This module is browser compatible.
export function stripTrailingSeparators( segment: string, isSep: (char: number) => boolean,): string { if (segment.length <= 1) { return segment; }
let end = segment.length;
for (let i = segment.length - 1; i > 0; i--) { if (isSep(segment.charCodeAt(i))) { end = i; } else { break; } }
return segment.slice(0, end);}
Version Info