@@ -43,7 +43,7 @@ export function ifNoneMatch(fieldValue: string, etag: string): boolean {
4343 return ifNoneMatch . every ( ( tag ) => ! compareWeak ( tag , etagObj ) ) ;
4444}
4545
46- /**
46+ /** Match `If-Modified-Since` field and `Last-Modified` field.
4747 * @throws {SyntaxError } If the input is invalid.
4848 */
4949export function ifModifiedSince (
@@ -53,13 +53,13 @@ export function ifModifiedSince(
5353 const date = parseHttpDate ( fieldValue . trim ( ) ) ;
5454
5555 if ( ! isValidDate ( date ) ) {
56- throw TypeError ( Msg . InvalidField ) ;
56+ throw SyntaxError ( Msg . InvalidField ) ;
5757 }
5858
5959 const lastMod = parseHttpDate ( lastModified . trim ( ) ) ;
6060
6161 if ( ! isValidDate ( lastMod ) ) {
62- throw TypeError ( Msg . InvalidLastModified ) ;
62+ throw SyntaxError ( Msg . InvalidLastModified ) ;
6363 }
6464
6565 // The origin server SHOULD NOT perform the requested
@@ -68,7 +68,7 @@ export function ifModifiedSince(
6868 return lastMod > date ;
6969}
7070
71- /**
71+ /** Match `If-Unmodified-Since` field and `Last-Modified` field.
7272 * @throws {SyntaxError } If the input is invalid.
7373 */
7474export function ifUnmodifiedSince (
@@ -78,13 +78,13 @@ export function ifUnmodifiedSince(
7878 const date = parseHttpDate ( fieldValue . trim ( ) ) ;
7979
8080 if ( ! isValidDate ( date ) ) {
81- throw TypeError ( Msg . InvalidField ) ;
81+ throw SyntaxError ( Msg . InvalidField ) ;
8282 }
8383
8484 const lastMod = parseHttpDate ( lastModified . trim ( ) ) ;
8585
8686 if ( ! isValidDate ( lastMod ) ) {
87- throw TypeError ( Msg . InvalidLastModified ) ;
87+ throw SyntaxError ( Msg . InvalidLastModified ) ;
8888 }
8989
9090 // The origin server MUST NOT perform the requested method
@@ -98,7 +98,7 @@ export interface IfRangeHeaders {
9898 readonly lastModified ?: string | null ;
9999}
100100
101- /**
101+ /** Match `If-Range` field `ETag` and `Last-Modified` field.
102102 * @throws {SyntaxError } If the input is invalid.
103103 */
104104export function ifRange ( fieldValue : string , headers : IfRangeHeaders ) : boolean {
@@ -117,13 +117,13 @@ export function ifRange(fieldValue: string, headers: IfRangeHeaders): boolean {
117117 const left = parseHttpDate ( fieldValue ) ;
118118
119119 if ( ! isValidDate ( left ) ) {
120- throw TypeError ( Msg . InvalidField ) ;
120+ throw SyntaxError ( Msg . InvalidField ) ;
121121 }
122122
123123 const right = parseHttpDate ( lastModified ) ;
124124
125125 if ( ! isValidDate ( right ) ) {
126- throw TypeError ( Msg . InvalidLastModified ) ;
126+ throw SyntaxError ( Msg . InvalidLastModified ) ;
127127 }
128128
129129 return left . getTime ( ) === right . getTime ( ) ;
0 commit comments