Skip to content

Commit c57efdb

Browse files
Merge pull request #2 from httpland/beta
Beta
2 parents 50e5693 + cbc5ef9 commit c57efdb

File tree

10 files changed

+57
-151
lines changed

10 files changed

+57
-151
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [1.0.1-beta.1](https://github.com/httpland/accept-ranges-parser/compare/1.0.0...1.0.1-beta.1) (2023-04-29)
2+
3+
4+
### Bug Fixes
5+
6+
* **parse:** accept list what includes empty element ([8dea1c5](https://github.com/httpland/accept-ranges-parser/commit/8dea1c5defe575b866ffb22b2a51cd468dbc00a3))
7+
18
# 1.0.0 (2023-03-27)
29

310

_tools/meta.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BuildOptions } from "https://deno.land/x/dnt@0.33.1/mod.ts";
1+
import { BuildOptions } from "https://deno.land/x/dnt@0.34.0/mod.ts";
22

33
export const makeOptions = (version: string): BuildOptions => ({
44
test: false,
@@ -37,10 +37,25 @@ export const makeOptions = (version: string): BuildOptions => ({
3737
},
3838
packageManager: "pnpm",
3939
mappings: {
40-
"https://deno.land/x/isx@1.1.0/is_string.ts": {
40+
"https://deno.land/x/isx@1.3.1/is_string.ts": {
4141
name: "@miyauci/isx",
42-
version: "1.1.0",
43-
subPath: "is_string",
42+
version: "1.3.1",
43+
subPath: "is_string.js",
44+
},
45+
"https://deno.land/x/[email protected]/iterable/is_not_empty.ts": {
46+
name: "@miyauci/isx",
47+
version: "1.3.1",
48+
subPath: "iterable/is_not_empty.js",
49+
},
50+
"https://deno.land/x/[email protected]/token.ts": {
51+
name: "@httpland/http-utils",
52+
version: "1.2.0",
53+
subPath: "token.js",
54+
},
55+
"https://deno.land/x/[email protected]/list.ts": {
56+
name: "@httpland/http-utils",
57+
version: "1.2.0",
58+
subPath: "list.js",
4459
},
4560
},
4661
});

_tools/publish_npm.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ if (import.meta.main) {
1616
const tag = isPrerelease?.[0] ?? "latest";
1717

1818
const pkg = makeOptions(version);
19-
const result = await Deno.run({
20-
cmd: ["npm", "publish", pkg.outDir, "--tag", String(tag)],
21-
stdout: "piped",
22-
})
23-
.output();
19+
const command = new Deno.Command("npm", {
20+
args: ["publish", pkg.outDir, "--tag", String(tag)],
21+
});
22+
const result = await command.output();
2423

25-
console.log(new TextDecoder().decode(result));
24+
if (!result.success) {
25+
console.error(new TextDecoder().decode(result.stderr));
26+
}
2627
}

deno.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps.ts

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

4-
export { isString } from "https://deno.land/x/[email protected]/is_string.ts";
5-
6-
// TODO:(miyauci) Packaging and externalization this module.
7-
8-
/** Types for uppercase letter. */
9-
export type UppercaseLetter =
10-
| "A"
11-
| "B"
12-
| "C"
13-
| "D"
14-
| "E"
15-
| "F"
16-
| "G"
17-
| "H"
18-
| "I"
19-
| "J"
20-
| "K"
21-
| "L"
22-
| "M"
23-
| "N"
24-
| "O"
25-
| "P"
26-
| "Q"
27-
| "R"
28-
| "S"
29-
| "T"
30-
| "U"
31-
| "V"
32-
| "W"
33-
| "X"
34-
| "Y"
35-
| "Z";
36-
37-
/** Types for lowercase letter. */
38-
export type LowercaseLetter = Lowercase<UppercaseLetter>;
39-
40-
/** Types for letter. */
41-
export type Letter = UppercaseLetter | LowercaseLetter;
42-
43-
/** Types for digit. */
44-
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
45-
46-
/** Deserialize types. */
47-
export type Stringify<
48-
T extends string | number | bigint | boolean | null | undefined,
49-
> = `${T}`;
50-
51-
/** Representation of [`<DIGIT>`](https://www.rfc-editor.org/rfc/rfc5234#appendix-B.1). */
52-
export type DIGIT = Stringify<Digit>;
53-
54-
/** Representation of [`<ALPHA>`](https://www.rfc-editor.org/rfc/rfc5234#appendix-B.1). */
55-
export type ALPHA = Letter;
56-
57-
/** Representation of [`<tchar>`](https://www.rfc-editor.org/rfc/rfc9110#section-5.6.2-2). */
58-
export type TChar =
59-
| "!"
60-
| "#"
61-
| "$"
62-
| "%"
63-
| "&"
64-
| "'"
65-
| "*"
66-
| "+"
67-
| "-"
68-
| "."
69-
| "^"
70-
| "_"
71-
| "`"
72-
| "|"
73-
| "~"
74-
| ALPHA
75-
| DIGIT;
76-
77-
/** Representation of [`<token>`](https://www.rfc-editor.org/rfc/rfc9110#section-5.6.2-2). */
78-
export type Token = `${TChar}${string}`;
4+
export { isString } from "https://deno.land/x/[email protected]/is_string.ts";
5+
export { isNotEmpty } from "https://deno.land/x/[email protected]/iterable/is_not_empty.ts";
6+
export {
7+
isToken,
8+
type Token,
9+
} from "https://deno.land/x/[email protected]/token.ts";
10+
export { parseListFields } from "https://deno.land/x/[email protected]/list.ts";

parse.ts

Lines changed: 6 additions & 8 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 { isTokenFormat } from "./utils.ts";
4+
import { isNotEmpty, isToken, parseListFields } from "./deps.ts";
55
import { Msg } from "./constants.ts";
66
import type { AcceptRanges } from "./types.ts";
77

@@ -18,15 +18,13 @@ import type { AcceptRanges } from "./types.ts";
1818
* @throws {SyntaxError} If the input is invalid [`<Accept-Ranges>`](https://www.rfc-editor.org/rfc/rfc9110.html#section-14.3-2) syntax.
1919
*/
2020
export function parseAcceptRanges(input: string): AcceptRanges {
21-
const acceptableRanges = input
22-
.trim()
23-
.split(",")
24-
.map((v) => v.trim());
21+
const acceptableRanges = parseListFields(input);
22+
const msg = `${Msg.InvalidSyntax} "${input}"`;
23+
24+
if (!isNotEmpty(acceptableRanges)) throw new SyntaxError(msg);
2525

2626
acceptableRanges.forEach((token) => {
27-
if (!isTokenFormat(token)) {
28-
throw SyntaxError(`${Msg.InvalidSyntax} "${input}"`);
29-
}
27+
if (!isToken(token)) throw new SyntaxError(msg);
3028
});
3129

3230
return acceptableRanges as AcceptRanges;

parse_test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ describe("parseAcceptRanges", () => {
1818
",",
1919
",,,",
2020
", , ,",
21-
"a,",
22-
"a, , a",
2321
"あ",
2422
"a, あ",
2523
`""`,
@@ -38,6 +36,7 @@ describe("parseAcceptRanges", () => {
3836
[" abc ", ["abc"]],
3937
["abc, def", ["abc", "def"]],
4038
["bytes,none", ["bytes", "none"]],
39+
["bytes, ,,none", ["bytes", "none"]],
4140
];
4241

4342
table.forEach(([input, expected]) => {

stringify.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { isString } from "./deps.ts";
2-
import { isTokenFormat } from "./utils.ts";
1+
import { isString, isToken } from "./deps.ts";
32
import { Msg } from "./constants.ts";
43

54
/** Serialize string of array into string.
@@ -20,7 +19,7 @@ export function stringifyAcceptRanges(
2019
const targets = isString(acceptRanges) ? [acceptRanges] : acceptRanges;
2120

2221
targets.forEach((rangeUnit) => {
23-
if (!isTokenFormat(rangeUnit)) {
22+
if (!isToken(rangeUnit)) {
2423
throw TypeError(`${Msg.InvalidRangeUnit} "${rangeUnit}"`);
2524
}
2625
});

utils.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

utils_test.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)