Merge pull request #310 from lbryio/startswith-null-error

added check for empty channel urls
This commit is contained in:
Bill Bittner 2017-12-28 11:17:41 -08:00 committed by GitHub
commit b2b2410c92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,9 @@ module.exports = {
logger.debug(`${proto}, ${value}, ${modifierSeperator}, ${modifier}`);
// Validate and process name
if (!value) {
throw new Error(`Check your url. No channel name provided before "${modifierSeperator}"`);
}
const isChannel = value.startsWith(module.exports.CHANNEL_CHAR);
const channelName = isChannel ? value : null;
let claimId;
@ -36,13 +39,13 @@ module.exports = {
let channelClaimId;
if (modifierSeperator) {
if (!modifier) {
throw new Error(`No modifier provided after separator ${modifierSeperator}.`);
throw new Error(`No modifier provided after separator "${modifierSeperator}"`);
}
if (modifierSeperator === ':') {
channelClaimId = modifier;
} else {
throw new Error(`The ${modifierSeperator} modifier is not currently supported.`);
throw new Error(`The "${modifierSeperator}" modifier is not currently supported`);
}
}
return {