fix: hard errors on URL issues

This commit is contained in:
Thomas Zarebczan 2019-12-21 14:23:50 -05:00
parent 0db20834f9
commit 1a61569405
2 changed files with 10 additions and 22 deletions

22
dist/bundle.es.js vendored
View file

@ -15,7 +15,6 @@ const CHANNEL_NEW = 'new';
const PAGE_SIZE = 20;
var claim = /*#__PURE__*/Object.freeze({
__proto__: null,
MINIMUM_PUBLISH_BID: MINIMUM_PUBLISH_BID,
CHANNEL_ANONYMOUS: CHANNEL_ANONYMOUS,
CHANNEL_NEW: CHANNEL_NEW,
@ -275,7 +274,6 @@ const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';
const USER_STATE_POPULATE = 'USER_STATE_POPULATE';
var action_types = /*#__PURE__*/Object.freeze({
__proto__: null,
WINDOW_FOCUSED: WINDOW_FOCUSED,
DAEMON_READY: DAEMON_READY,
DAEMON_VERSION_MATCH: DAEMON_VERSION_MATCH,
@ -518,7 +516,6 @@ const OTHER = 'other';
const COPYRIGHT = 'copyright';
var licenses = /*#__PURE__*/Object.freeze({
__proto__: null,
CC_LICENSES: CC_LICENSES,
NONE: NONE,
PUBLIC_DOMAIN: PUBLIC_DOMAIN,
@ -549,7 +546,6 @@ const HISTORY = 'user_history';
const WALLET = 'wallet';
var pages = /*#__PURE__*/Object.freeze({
__proto__: null,
AUTH: AUTH,
BACKUP: BACKUP,
CHANNEL: CHANNEL,
@ -599,7 +595,6 @@ const RECEIVE_INTERESTS_NOTIFICATIONS = 'receiveInterestsNotifications';
const RECEIVE_CREATOR_NOTIFICATIONS = 'receiveCreatorNotifications';
var settings = /*#__PURE__*/Object.freeze({
__proto__: null,
CREDIT_REQUIRED_ACKNOWLEDGED: CREDIT_REQUIRED_ACKNOWLEDGED,
NEW_USER_ACKNOWLEDGED: NEW_USER_ACKNOWLEDGED,
EMAIL_COLLECTION_ACKNOWLEDGED: EMAIL_COLLECTION_ACKNOWLEDGED,
@ -627,7 +622,6 @@ const TITLE = 'title';
const FILENAME = 'filename';
var sort_options = /*#__PURE__*/Object.freeze({
__proto__: null,
DATE_NEW: DATE_NEW,
DATE_OLD: DATE_OLD,
TITLE: TITLE,
@ -641,7 +635,6 @@ const COMPLETE = 'complete';
const MANUAL = 'manual';
var thumbnail_upload_statuses = /*#__PURE__*/Object.freeze({
__proto__: null,
API_DOWN: API_DOWN,
READY: READY,
IN_PROGRESS: IN_PROGRESS,
@ -661,7 +654,6 @@ const UPDATE = 'update';
const ABANDON = 'abandon';
var transaction_types = /*#__PURE__*/Object.freeze({
__proto__: null,
ALL: ALL,
SPEND: SPEND,
RECEIVE: RECEIVE,
@ -678,7 +670,6 @@ const PAGE_SIZE$1 = 50;
const LATEST_PAGE_SIZE = 20;
var transaction_list = /*#__PURE__*/Object.freeze({
__proto__: null,
PAGE_SIZE: PAGE_SIZE$1,
LATEST_PAGE_SIZE: LATEST_PAGE_SIZE
});
@ -687,7 +678,6 @@ const SPEECH_STATUS = 'https://spee.ch/api/config/site/publishing';
const SPEECH_PUBLISH = 'https://spee.ch/api/claim/publish';
var speech_urls = /*#__PURE__*/Object.freeze({
__proto__: null,
SPEECH_STATUS: SPEECH_STATUS,
SPEECH_PUBLISH: SPEECH_PUBLISH
});
@ -733,7 +723,6 @@ const WALLET_DIR = 'wallet_dir';
const WALLETS = 'wallets';
var daemon_settings = /*#__PURE__*/Object.freeze({
__proto__: null,
ANNOUNCE_HEAD_AND_SD_ONLY: ANNOUNCE_HEAD_AND_SD_ONLY,
API: API,
BLOB_DOWNLOAD_TIMEOUT: BLOB_DOWNLOAD_TIMEOUT,
@ -787,7 +776,6 @@ var daemon_settings = /*#__PURE__*/Object.freeze({
const WALLET_SERVERS = LBRYUM_SERVERS;
var shared_preferences = /*#__PURE__*/Object.freeze({
__proto__: null,
WALLET_SERVERS: WALLET_SERVERS
});
@ -1133,17 +1121,17 @@ function parseURI(URL, requireProto = false) {
// Validate protocol
if (requireProto && !proto) {
throw new Error(__('LBRY URLs must include a protocol prefix (lbry://).'));
console.error(__('LBRY URLs must include a protocol prefix (lbry://).'));
}
// Validate and process name
if (!streamNameOrChannelName) {
throw new Error(__('URL does not include name.'));
console.error(__('URL does not include name.'));
}
rest.forEach(urlPiece => {
if (urlPiece && urlPiece.includes(' ')) {
throw new Error('URL can not include a space');
console.error('URL can not include a space');
}
});
@ -1153,11 +1141,11 @@ function parseURI(URL, requireProto = false) {
if (includesChannel) {
if (!channelName) {
throw new Error(__('No channel name after @.'));
console.error(__('No channel name after @.'));
}
if (channelName.length < channelNameMinLength) {
throw new Error(__(`Channel names must be at least %channelNameMinLength% characters.`, {
console.error(__(`Channel names must be at least %channelNameMinLength% characters.`, {
channelNameMinLength
}));
}

View file

@ -63,17 +63,17 @@ export function parseURI(URL: string, requireProto: boolean = false): LbryUrlObj
// Validate protocol
if (requireProto && !proto) {
throw new Error(__('LBRY URLs must include a protocol prefix (lbry://).'));
console.error(__('LBRY URLs must include a protocol prefix (lbry://).'));
}
// Validate and process name
if (!streamNameOrChannelName) {
throw new Error(__('URL does not include name.'));
console.error(__('URL does not include name.'));
}
rest.forEach(urlPiece => {
if (urlPiece && urlPiece.includes(' ')) {
throw new Error('URL can not include a space');
console.error('URL can not include a space');
}
});
@ -83,11 +83,11 @@ export function parseURI(URL: string, requireProto: boolean = false): LbryUrlObj
if (includesChannel) {
if (!channelName) {
throw new Error(__('No channel name after @.'));
console.error(__('No channel name after @.'));
}
if (channelName.length < channelNameMinLength) {
throw new Error(
console.error(
__(`Channel names must be at least %channelNameMinLength% characters.`, {
channelNameMinLength,
})