Go to Latest
function matchAfterPrefix
import { matchAfterPrefix } from "https://dotland.deno.dev/std@0.131.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