Rename isHttpUrl to isWebUri in assert package

This commit is contained in:
Brandon Millman 2018-03-05 15:24:55 -08:00
parent d355382f70
commit 08ab81c54c
5 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,9 @@
# CHANGELOG # CHANGELOG
## v0.2.0 - _TBD, 2018_
* Rename `isHttpUrl` to `isWebUri` (#412)
## v0.1.0 - _March 4, 2018_ ## v0.1.0 - _March 4, 2018_
* Remove isETHAddressHex checksum address check and assume address will be lowercased (#373) * Remove isETHAddressHex checksum address check and assume address will be lowercased (#373)

View File

@ -75,9 +75,9 @@ Encountered: ${JSON.stringify(value, null, '\t')}
Validation errors: ${validationResult.errors.join(', ')}`; Validation errors: ${validationResult.errors.join(', ')}`;
this.assert(!hasValidationErrors, msg); this.assert(!hasValidationErrors, msg);
}, },
isHttpUrl(variableName: string, value: any): void { isWebUri(variableName: string, value: any): void {
const isValidUrl = !_.isUndefined(validUrl.isWebUri(value)); const isValidUrl = !_.isUndefined(validUrl.isWebUri(value));
this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'http url', value)); this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'web uri', value));
}, },
isUri(variableName: string, value: any): void { isUri(variableName: string, value: any): void {
const isValidUri = !_.isUndefined(validUrl.isUri(value)); const isValidUri = !_.isUndefined(validUrl.isUri(value));

View File

@ -183,7 +183,7 @@ describe('Assertions', () => {
); );
}); });
}); });
describe('#isHttpUrl', () => { describe('#isWebUri', () => {
it('should not throw for valid input', () => { it('should not throw for valid input', () => {
const validInputs = [ const validInputs = [
'http://www.google.com', 'http://www.google.com',
@ -191,7 +191,7 @@ describe('Assertions', () => {
'https://api.radarrelay.com/0x/v0/', 'https://api.radarrelay.com/0x/v0/',
'https://zeroex.beta.radarrelay.com:8000/0x/v0/', 'https://zeroex.beta.radarrelay.com:8000/0x/v0/',
]; ];
validInputs.forEach(input => expect(assert.isHttpUrl.bind(assert, variableName, input)).to.not.throw()); validInputs.forEach(input => expect(assert.isWebUri.bind(assert, variableName, input)).to.not.throw());
}); });
it('should throw for invalid input', () => { it('should throw for invalid input', () => {
const invalidInputs = [ const invalidInputs = [
@ -205,7 +205,7 @@ describe('Assertions', () => {
'user:password@api.example-relayer.net', 'user:password@api.example-relayer.net',
'//api.example-relayer.net', '//api.example-relayer.net',
]; ];
invalidInputs.forEach(input => expect(assert.isHttpUrl.bind(assert, variableName, input)).to.throw()); invalidInputs.forEach(input => expect(assert.isWebUri.bind(assert, variableName, input)).to.throw());
}); });
}); });
describe('#isUri', () => { describe('#isUri', () => {

View File

@ -61,7 +61,7 @@ export class HttpClient implements Client {
* @return An instance of HttpClient * @return An instance of HttpClient
*/ */
constructor(url: string) { constructor(url: string) {
assert.isHttpUrl('url', url); assert.isWebUri('url', url);
this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes
} }
/** /**

View File

@ -42,7 +42,7 @@ const args = yargs
.argv; .argv;
// perform extra validation on command line arguments // perform extra validation on command line arguments
try { try {
assert.isHttpUrl('args', args.url); assert.isWebUri('args', args.url);
} catch (err) { } catch (err) {
utils.log(`${chalk.red(`Invalid url format:`)} ${args.url}`); utils.log(`${chalk.red(`Invalid url format:`)} ${args.url}`);
process.exit(1); process.exit(1);