| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Split a path into [dirname, basename]. |
| 10 | */ |
| 11 | export default function splitPath(path: string): [string, string] { |
| 12 | const index = path.lastIndexOf('/'); |
| 13 | if (index !== -1) { |
| 14 | return [path.slice(0, index), path.slice(index + 1)]; |
| 15 | } else { |
| 16 | return ['', path]; |
| 17 | } |
| 18 | } |
| 19 |