# 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; | |
}; | |
} |