Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function matchAfterPrefix
import { matchAfterPrefix } from "https://deno.land/std@0.98.0/mime/multipart.ts";

Checks whether buf should be considered to match the boundary.

The prefix is "--boundary" or "\r\n--boundary" or "\n--boundary", and the caller has verified already that hasPrefix(buf, prefix) is true.

matchAfterPrefix() returns 1 if the buffer does match the boundary, meaning the prefix is followed by a dash, space, tab, cr, nl, or EOF.

It returns -1 if the buffer definitely does NOT match the boundary, meaning the prefix is followed by some other character. For example, "--foobar" does not match "--foo".

It returns 0 more input needs to be read to make the decision, meaning that buf.length and prefix.length are the same.

Parameters

buf: Uint8Array
prefix: Uint8Array
eof: boolean

Returns

-1 | 0 | 1