Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/std/mime/multipart.ts>matchAfterPrefix

A modern runtime for JavaScript and TypeScript.
Go to Latest
function matchAfterPrefix
import { matchAfterPrefix } from "https://deno.land/x/deno@v0.28.0/std/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