@@ -39,7 +39,6 @@ var format = require( '@stdlib/string/format' );
39
39
* @param {Options } options - function options
40
40
* @param {string } [options.address] - server address
41
41
* @param {string } [options.hostname] - server hostname
42
- * @param {string } [options.latest] - latest version
43
42
* @param {(boolean|string) } [options.logger] - either boolean indicating whether to enable logging or a log level
44
43
* @param {NonNegativeInteger } [options.port] - server port
45
44
* @param {(string|StringArray) } [options.prefix] - URL path prefix(es) used to create a virtual mount path(s) for static directories
@@ -67,19 +66,13 @@ function validate( opts, options ) {
67
66
if ( hasOwnProp ( options , 'address' ) ) {
68
67
opts . address = options . address ;
69
68
if ( ! isString ( opts . address ) ) {
70
- return new TypeError ( format ( 'invalid option. `address ` option must be a string. Option: `%s`.' , opts . address ) ) ;
69
+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string. Option: `%s`.' , 'address ', opts . address ) ) ;
71
70
}
72
71
}
73
72
if ( hasOwnProp ( options , 'hostname' ) ) {
74
73
opts . hostname = options . hostname ;
75
74
if ( ! isString ( opts . hostname ) ) {
76
- return new TypeError ( format ( 'invalid option. `hostname` option must be a string. Option: `%s`.' , opts . hostname ) ) ;
77
- }
78
- }
79
- if ( hasOwnProp ( options , 'latest' ) ) {
80
- opts . latest = options . latest ;
81
- if ( ! isString ( opts . latest ) ) {
82
- return new TypeError ( format ( 'invalid option. `latest` option must be a string. Option: `%s`.' , opts . latest ) ) ;
75
+ return new TypeError ( format ( 'invalid option. `%s` option must be a string. Option: `%s`.' , 'hostname' , opts . hostname ) ) ;
83
76
}
84
77
}
85
78
if ( hasOwnProp ( options , 'logger' ) ) {
@@ -89,43 +82,43 @@ function validate( opts, options ) {
89
82
'level' : opts . logger
90
83
} ;
91
84
} else if ( ! isBoolean ( opts . logger ) ) {
92
- return new TypeError ( format ( 'invalid option. `logger ` option must be either a boolean or a string. Option: `%s`.' , opts . logger ) ) ;
85
+ return new TypeError ( format ( 'invalid option. `%s ` option must be either a boolean or a string. Option: `%s`.' , 'logger ', opts . logger ) ) ;
93
86
}
94
87
}
95
88
if ( hasOwnProp ( options , 'port' ) ) {
96
89
opts . port = options . port ;
97
90
if ( ! isNonNegativeInteger ( opts . port ) ) {
98
- return new TypeError ( format ( 'invalid option. `port ` must be a nonnegative integer. Option: `%s`.' , opts . port ) ) ;
91
+ return new TypeError ( format ( 'invalid option. `%s ` must be a nonnegative integer. Option: `%s`.' , 'port ', opts . port ) ) ;
99
92
}
100
93
}
101
94
if ( hasOwnProp ( options , 'prefix' ) ) {
102
95
opts . prefix = options . prefix ;
103
96
if ( ! isString ( opts . prefix ) && ! isStringArray ( opts . prefix ) ) {
104
- return new TypeError ( format ( 'invalid option. `prefix ` option must be either a string or an array of strings. Option: `%s`.' , opts . prefix ) ) ;
97
+ return new TypeError ( format ( 'invalid option. `%s ` option must be either a string or an array of strings. Option: `%s`.' , 'prefix ', opts . prefix ) ) ;
105
98
}
106
99
}
107
100
if ( hasOwnProp ( options , 'root' ) ) {
108
101
opts . root = options . root ;
109
102
if ( ! isString ( opts . root ) ) {
110
- return new TypeError ( format ( 'invalid option. `root ` option must be a string. Option: `%s`.' , opts . root ) ) ;
103
+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string. Option: `%s`.' , 'root ', opts . root ) ) ;
111
104
}
112
105
}
113
106
if ( hasOwnProp ( options , 'static' ) ) {
114
107
opts . static = options . static ;
115
108
if ( ! isString ( opts . static ) && ! isStringArray ( opts . static ) ) {
116
- return new TypeError ( format ( 'invalid option. `static ` option must be either a string or an array of strings. Option: `%s`.' , opts . static ) ) ;
109
+ return new TypeError ( format ( 'invalid option. `%s ` option must be either a string or an array of strings. Option: `%s`.' , 'static ', opts . static ) ) ;
117
110
}
118
111
}
119
112
if ( hasOwnProp ( options , 'trustProxy' ) ) {
120
113
opts . trustProxy = options . trustProxy ;
121
114
if ( ! isBoolean ( opts . trustProxy ) ) {
122
- return new TypeError ( format ( 'invalid option. `trustProxy ` option must be a boolean. Option: `%s`.' , opts . trustProxy ) ) ;
115
+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean. Option: `%s`.' , 'trustProxy ', opts . trustProxy ) ) ;
123
116
}
124
117
}
125
118
if ( hasOwnProp ( options , 'ignoreTrailingSlash' ) ) {
126
119
opts . ignoreTrailingSlash = options . ignoreTrailingSlash ;
127
120
if ( ! isBoolean ( opts . ignoreTrailingSlash ) ) {
128
- return new TypeError ( format ( 'invalid option. `ignoreTrailingSlash ` option must be a boolean. Option: `%s`.' , opts . ignoreTrailingSlash ) ) ;
121
+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean. Option: `%s`.' , 'ignoreTrailingSlash ', opts . ignoreTrailingSlash ) ) ;
129
122
}
130
123
}
131
124
return null ;
@@ -134,4 +127,4 @@ function validate( opts, options ) {
134
127
135
128
// EXPORTS //
136
129
137
- module . exports = validate ;
130
+ module . exports = validate ;
0 commit comments