Skyler Grey | 82ea805 | 2024-06-08 22:56:00 +0000 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2024 Clicks Codes |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-3.0-only |
| 4 | |
| 5 | { lib, inputs, ... }: |
| 6 | { |
| 7 | strings = { |
| 8 | getCommonPrefix = |
| 9 | a: b: |
| 10 | let |
| 11 | prefixLength = lib.strings.commonPrefixLength a b; |
| 12 | in |
| 13 | builtins.substring 0 prefixLength a; |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 14 | |
| 15 | endsWith = suffix: str: let |
| 16 | suffixLength = builtins.stringLength suffix; |
| 17 | strLength = builtins.stringLength str; |
| 18 | |
| 19 | suffixStart = strLength - suffixLength; |
| 20 | |
| 21 | maybeSuffix = builtins.substring suffixStart strLength str; |
| 22 | in suffixStart >= 0 && maybeSuffix == suffix; |
Skyler Grey | 82ea805 | 2024-06-08 22:56:00 +0000 | [diff] [blame] | 23 | }; |
| 24 | } |