blob: ca056e086e124fbbefb232fb396c398bf5c64c34 [file] [log] [blame]
Skyler Grey82ea8052024-06-08 22:56:00 +00001# 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 Greye6a8c712024-06-22 01:41:28 +000014
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 Grey82ea8052024-06-08 22:56:00 +000023 };
24}