Skip to content

Commit 0e1c1a4

Browse files
committed
refactor(deps): use external module
1 parent 1928b53 commit 0e1c1a4

File tree

6 files changed

+21
-95
lines changed

6 files changed

+21
-95
lines changed

_tools/meta.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ export const makeOptions = (version: string): BuildOptions => ({
4444
version: "1.2.0",
4545
subPath: "to_lower_case.js",
4646
},
47-
"https://deno.land/x/[email protected]/trim.ts": {
48-
name: "@miyauci/prelude",
49-
version: "1.2.0",
50-
subPath: "trim.js",
51-
},
5247
"https://deno.land/x/[email protected]/head.ts": {
5348
name: "@miyauci/prelude",
5449
version: "1.2.0",
@@ -64,15 +59,20 @@ export const makeOptions = (version: string): BuildOptions => ({
6459
version: "1.3.1",
6560
subPath: "is_nullable.js",
6661
},
67-
"https://deno.land/x/http_utils@1.1.0/quoted_string.ts": {
62+
"https://deno.land/x/http_utils@1.2.0/quoted_string.ts": {
6863
name: "@httpland/http-utils",
69-
version: "1.1.0",
64+
version: "1.2.0",
7065
subPath: "quoted_string.js",
7166
},
72-
"https://deno.land/x/http_utils@1.1.0/token.ts": {
67+
"https://deno.land/x/http_utils@1.2.0/token.ts": {
7368
name: "@httpland/http-utils",
74-
version: "1.1.0",
69+
version: "1.2.0",
7570
subPath: "token.js",
7671
},
72+
"https://deno.land/x/[email protected]/list.ts": {
73+
name: "@httpland/http-utils",
74+
version: "1.2.0",
75+
subPath: "list.js",
76+
},
7777
},
7878
});

deno.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// This module is browser compatible.
33

44
export { toLowerCase } from "https://deno.land/x/[email protected]/to_lower_case.ts";
5-
export { trim } from "https://deno.land/x/[email protected]/trim.ts";
65
export { head } from "https://deno.land/x/[email protected]/head.ts";
76
export { isString } from "https://deno.land/x/[email protected]/is_string.ts";
87
export { isNullable } from "https://deno.land/x/[email protected]/is_nullable.ts";
98
export { mapValues } from "https://deno.land/[email protected]/collections/map_values.ts";
10-
export { isQuotedString } from "https://deno.land/x/[email protected]/quoted_string.ts";
11-
export { isToken } from "https://deno.land/x/[email protected]/token.ts";
9+
export { isQuotedString } from "https://deno.land/x/[email protected]/quoted_string.ts";
10+
export { isToken } from "https://deno.land/x/[email protected]/token.ts";
11+
export { parseListFields } from "https://deno.land/x/[email protected]/list.ts";

parse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
22
// This module is browser compatible.
33

4-
import { duplicate, parseList } from "./utils.ts";
5-
import { head, isString, toLowerCase } from "./deps.ts";
4+
import { duplicate } from "./utils.ts";
5+
import { head, isString, parseListFields, toLowerCase } from "./deps.ts";
66
import { Msg } from "./constants.ts";
77
import type { Authorization, AuthParams } from "./types.ts";
88

@@ -74,7 +74,7 @@ type AuthParamGroups =
7474
* @throws {Error} If the auth param key is duplicated.
7575
*/
7676
export function parseAuthParams(input: string): AuthParams {
77-
const list = parseList(input);
77+
const list = parseListFields(input);
7878

7979
const entries = list.map((el) => {
8080
const result = reAuthParam.exec(el);

utils.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
22
// This module is browser compatible.
33

4-
import { isToken, trim } from "./deps.ts";
4+
import { isToken } from "./deps.ts";
55

66
export function duplicate<T>(list: readonly T[]): T[] {
77
const duplicates = new Set<T>();
@@ -15,16 +15,6 @@ export function duplicate<T>(list: readonly T[]): T[] {
1515
return [...duplicates];
1616
}
1717

18-
const reCommaSplitWithoutDQuote = /,(?=(?:(?:[^"]*"){2})*[^"]*$)/;
19-
20-
/** Parse string into list-based field. */
21-
export function parseList(input: string): string[] {
22-
return input
23-
.split(reCommaSplitWithoutDQuote)
24-
.map(trim)
25-
.filter(Boolean);
26-
}
27-
2818
/**
2919
* ```abnf
3020
* token68 = 1*( ALPHA / DIGIT /

utils_test.ts

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,12 @@
1-
import { assertToken, assertToken68, isToken68, parseList } from "./utils.ts";
1+
import { assertToken, assertToken68, isToken68 } from "./utils.ts";
22
import {
33
assert,
4-
assertEquals,
54
assertFalse,
65
assertThrows,
76
describe,
87
it,
98
} from "./_dev_deps.ts";
109

11-
describe("parseList", () => {
12-
it("should return", () => {
13-
const table: [string, string[]][] = [
14-
["", []],
15-
[",", []],
16-
[",, , , , ", []],
17-
["a", ["a"]],
18-
["a, b", ["a", "b"]],
19-
["a, b,", ["a", "b"]],
20-
["a, b,,,,", ["a", "b"]],
21-
["a, b, c", ["a", "b", "c"]],
22-
["a,b,c", ["a", "b", "c"]],
23-
["a,,c", ["a", "c"]],
24-
[",,,", []],
25-
[`"a,b"`, [`"a,b"`]],
26-
[`"a,b",c, "d,e", f f , g `, [`"a,b"`, "c", `"d,e"`, "f f", "g"]],
27-
[` complex,pattern,"abc", "abc , def", ,,,, """, , ",""`, [
28-
"complex",
29-
"pattern",
30-
`"abc"`,
31-
`"abc , def"`,
32-
`""", , "`,
33-
`""`,
34-
]],
35-
[`",","`, [`"`, `","`]],
36-
[`",",","`, [`","`, `","`]],
37-
[`",",",",`, [`","`, `","`]],
38-
[`",",",","`, [`"`, `","`, `","`]],
39-
[`",",",",",`, [`"`, `","`, `","`]],
40-
[`",",",",","`, [`","`, `","`, `","`]],
41-
[`"`, [`"`]],
42-
[`""`, [`""`]],
43-
[`"""`, [`"""`]],
44-
[`""""`, [`""""`]],
45-
[`"",""`, [`""`, `""`]],
46-
[`",",`, [`","`]],
47-
[`"abc,def", "efg, hij", "lmn, opq"`, [
48-
'"abc,def"',
49-
'"efg, hij"',
50-
'"lmn, opq"',
51-
]],
52-
// ["()", [`()`]],
53-
// ["(), ()", [`()`, `()`]],
54-
// ["(, ()", [`(`, `()`]],
55-
// ["(,), ()", [`(,)`, `()`]],
56-
// ["(,), , ()", [`(,)`, `()`]],
57-
// ["(,),,,, ()", [`(,)`, `()`]],
58-
// ["(,),(),(, ()", [`(,)`, `()`, `(`, `()`]],
59-
// ["(, ), ), (", [`(, ), )`, "("]],
60-
// [`(", ", ), ", (, ", (",`, []],
61-
// [`(), "()", (""), (,), "(,)", "(), (a), (b, c)", ("a", "b", "c",) `, [
62-
// "()",
63-
// `"()"`,
64-
// `("")`,
65-
// `(,)`,
66-
// `"(,)"`,
67-
// `"(), (a), (b, c)"`,
68-
// `("a", "b", "c",)`,
69-
// ]],
70-
];
71-
72-
table.forEach(([input, expected]) => {
73-
assertEquals(parseList(input), expected);
74-
});
75-
});
76-
});
77-
7810
describe("isToken68", () => {
7911
it("should return true", () => {
8012
const table: string[] = [

0 commit comments

Comments
 (0)