addons/shared/textmate-lib/splitPath.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318/**
b69ab319 * Split a path into [dirname, basename].
b69ab3110 */
b69ab3111export default function splitPath(path: string): [string, string] {
b69ab3112 const index = path.lastIndexOf('/');
b69ab3113 if (index !== -1) {
b69ab3114 return [path.slice(0, index), path.slice(index + 1)];
b69ab3115 } else {
b69ab3116 return ['', path];
b69ab3117 }
b69ab3118}