function parseRequestKind
parseRequestKind(target: string): RequestReference

Which request an argument names: a name (#3), a position counted back (2), or a URL.

The # is what tells the first two apart, and they answer different questions: a position moves as you work — 2 is the one before last, whichever that is now — while an id is the name a request keeps for the session. Everything else is a URL, matched the forgiving way.

import { parseRequestKind } from './http-service.ts';

parseRequestKind('#3'); // { kind: 'id', id: 3 }
parseRequestKind('2'); // { kind: 'position', back: 2 }
parseRequestKind('post:/api/users'); // { kind: 'url', verb: 'POST', url: '/api/users' }

Parameters

target: string

Return Type

Usage

import { parseRequestKind } from "lib/repl/http-service.ts";