From 3fd7c14fa9ed3bb89c24f9bd6c74b18014077f4c Mon Sep 17 00:00:00 2001 From: Mikkel ALMONTE--RINGAUD Date: Sat, 17 Aug 2024 17:36:36 +0200 Subject: [PATCH] feat: add `findValueBetween()` --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 90fc6b8..13313f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,11 @@ import { splitCookiesString } from "set-cookie-parser"; +export const findValueBetween = (plain: string, start: string, end: string): string => { + const startIndex = plain.indexOf(start) + start.length; + const endIndex = plain.indexOf(end, startIndex); + return plain.slice(startIndex, endIndex); +}; + interface HeadersLike { get (key: string): string | null };