blob: ca056e086e124fbbefb232fb396c398bf5c64c34 [file] [log] [blame]
# SPDX-FileCopyrightText: 2024 Clicks Codes
#
# SPDX-License-Identifier: GPL-3.0-only
{ lib, inputs, ... }:
{
strings = {
getCommonPrefix =
a: b:
let
prefixLength = lib.strings.commonPrefixLength a b;
in
builtins.substring 0 prefixLength a;
endsWith = suffix: str: let
suffixLength = builtins.stringLength suffix;
strLength = builtins.stringLength str;
suffixStart = strLength - suffixLength;
maybeSuffix = builtins.substring suffixStart strLength str;
in suffixStart >= 0 && maybeSuffix == suffix;
};
}