File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,29 @@ const reAuthorization =
1414 / ^ (?< authScheme > [ ! # $ % & ' * + . ^ _ ` | ~ \d A - Z a - z - ] + ) (?: + (?: (?< token68 > (?: [ A - Z a - z ] | \d | [ - . _ ~ + / ] ) + = * ) | (?< authParam > .+ ) ) ) ? $ / ;
1515
1616/** Parse string into {@link Authorization}.
17+ *
18+ * @example
19+ * ```ts
20+ * import { parseAuthorization } from "https://deno.land/x/authorization_parser@$VERSION/parse.ts";
21+ * import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
22+ *
23+ * const result = parseAuthorization("Basic token68");
24+ *
25+ * assertEquals(parseAuthorization("Basic token68"), {
26+ * authScheme: "Basic",
27+ * token: "token68",
28+ * });
29+ * assertEquals(
30+ * parseAuthorization(`Bearer realm="example", error="invalid_token"`),
31+ * {
32+ * authScheme: "Bearer",
33+ * token: {
34+ * realm: `"example"`,
35+ * error: `"invalid_token"`,
36+ * },
37+ * },
38+ * );
39+ * ```
1740 *
1841 * @throws {SyntaxError } If the input is invalid.
1942 * @throws {Error } If the auth param key is duplicated.
You can’t perform that action at this time.
0 commit comments