From e0adbf3ebbe5a487e64622e96b293607fc924e61 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 14 Nov 2024 16:03:02 -0700 Subject: [PATCH] AK: Add a Swift helper for StringView::ends_with --- AK/AK+Swift.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AK/AK+Swift.swift b/AK/AK+Swift.swift index b42241f9642..4f13f29f5db 100644 --- a/AK/AK+Swift.swift +++ b/AK/AK+Swift.swift @@ -29,4 +29,11 @@ extension AK.StringView: ExpressibleByStringLiteral { public init(stringLiteral value: StringLiteralType) { self.init(value.utf8Start, value.utf8CodeUnitCount) } + + public func endsWith(_ suffix: AK.StringView) -> Bool { + if suffix.length() == 1 { + return self.ends_with(suffix[0]) + } + return self.ends_with(suffix, AK.CaseSensitivity.sensitive) + } }