bring app in line with new spec re separators :,#,$
This commit is contained in:
parent
acc54f157f
commit
308ee84391
6 changed files with 38 additions and 161 deletions
91
dist/bundle.es.js
vendored
91
dist/bundle.es.js
vendored
|
@ -1370,11 +1370,11 @@ const channelNameMinLength = 1;
|
||||||
const claimIdMaxLength = 40;
|
const claimIdMaxLength = 40;
|
||||||
|
|
||||||
// see https://spec.lbry.com/#urls
|
// see https://spec.lbry.com/#urls
|
||||||
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%\{\}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%{}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
||||||
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
||||||
const regexPartProtocol = '^((?:lbry://)?)';
|
const regexPartProtocol = '^((?:lbry://)?)';
|
||||||
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
||||||
const regexPartModifierSeparator = '([:$#]?)([^/]*)';
|
const regexPartModifierSeparator = '([:#]?)([^/]*)';
|
||||||
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
||||||
const separateQuerystring = new RegExp(queryStringBreaker);
|
const separateQuerystring = new RegExp(queryStringBreaker);
|
||||||
|
|
||||||
|
@ -1389,10 +1389,6 @@ const separateQuerystring = new RegExp(queryStringBreaker);
|
||||||
* - streamClaimId (string, if present)
|
* - streamClaimId (string, if present)
|
||||||
* - channelName (string, if present)
|
* - channelName (string, if present)
|
||||||
* - channelClaimId (string, if present)
|
* - channelClaimId (string, if present)
|
||||||
* - primaryClaimSequence (int, if present)
|
|
||||||
* - secondaryClaimSequence (int, if present)
|
|
||||||
* - primaryBidPosition (int, if present)
|
|
||||||
* - secondaryBidPosition (int, if present)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function parseURI(url, requireProto = false) {
|
function parseURI(url, requireProto = false) {
|
||||||
|
@ -1451,8 +1447,8 @@ function parseURI(url, requireProto = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate and process modifier
|
// Validate and process modifier
|
||||||
const [primaryClaimId, primaryClaimSequence, primaryBidPosition] = parseURIModifier(primaryModSeparator, primaryModValue);
|
const [primaryClaimId] = parseURIModifier(primaryModSeparator, primaryModValue);
|
||||||
const [secondaryClaimId, secondaryClaimSequence, secondaryBidPosition] = parseURIModifier(secondaryModSeparator, secondaryModValue);
|
const [secondaryClaimId] = parseURIModifier(secondaryModSeparator, secondaryModValue);
|
||||||
const streamName = includesChannel ? possibleStreamName : streamNameOrChannelName;
|
const streamName = includesChannel ? possibleStreamName : streamNameOrChannelName;
|
||||||
const streamClaimId = includesChannel ? secondaryClaimId : primaryClaimId;
|
const streamClaimId = includesChannel ? secondaryClaimId : primaryClaimId;
|
||||||
const channelClaimId = includesChannel && primaryClaimId;
|
const channelClaimId = includesChannel && primaryClaimId;
|
||||||
|
@ -1460,7 +1456,7 @@ function parseURI(url, requireProto = false) {
|
||||||
return _extends({
|
return _extends({
|
||||||
isChannel,
|
isChannel,
|
||||||
path
|
path
|
||||||
}, streamName ? { streamName } : {}, streamClaimId ? { streamClaimId } : {}, channelName ? { channelName } : {}, channelClaimId ? { channelClaimId } : {}, primaryClaimSequence ? { primaryClaimSequence: parseInt(primaryClaimSequence, 10) } : {}, secondaryClaimSequence ? { secondaryClaimSequence: parseInt(secondaryClaimSequence, 10) } : {}, primaryBidPosition ? { primaryBidPosition: parseInt(primaryBidPosition, 10) } : {}, secondaryBidPosition ? { secondaryBidPosition: parseInt(secondaryBidPosition, 10) } : {}, startTime ? { startTime: parseInt(startTime, 10) } : {}, {
|
}, streamName ? { streamName } : {}, streamClaimId ? { streamClaimId } : {}, channelName ? { channelName } : {}, channelClaimId ? { channelClaimId } : {}, startTime ? { startTime: parseInt(startTime, 10) } : {}, {
|
||||||
|
|
||||||
// The values below should not be used for new uses of parseURI
|
// The values below should not be used for new uses of parseURI
|
||||||
// They will not work properly with canonical_urls
|
// They will not work properly with canonical_urls
|
||||||
|
@ -1471,20 +1467,14 @@ function parseURI(url, requireProto = false) {
|
||||||
|
|
||||||
function parseURIModifier(modSeperator, modValue) {
|
function parseURIModifier(modSeperator, modValue) {
|
||||||
let claimId;
|
let claimId;
|
||||||
let claimSequence;
|
|
||||||
let bidPosition;
|
|
||||||
|
|
||||||
if (modSeperator) {
|
if (modSeperator) {
|
||||||
if (!modValue) {
|
if (!modValue) {
|
||||||
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modSeperator === '#') {
|
if (modSeperator === '#' || modSeperator === ':') {
|
||||||
claimId = modValue;
|
claimId = modValue;
|
||||||
} else if (modSeperator === ':') {
|
|
||||||
claimSequence = modValue;
|
|
||||||
} else if (modSeperator === '$') {
|
|
||||||
bidPosition = modValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1492,15 +1482,7 @@ function parseURIModifier(modSeperator, modValue) {
|
||||||
throw new Error(__(`Invalid claim ID %claimId%.`, { claimId }));
|
throw new Error(__(`Invalid claim ID %claimId%.`, { claimId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {
|
return [claimId];
|
||||||
throw new Error(__('Claim sequence must be a number.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bidPosition && !bidPosition.match(/^-?[1-9][0-9]*$/)) {
|
|
||||||
throw new Error(__('Bid position must be a number.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return [claimId, claimSequence, bidPosition];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1514,13 +1496,9 @@ function buildURI(UrlObj, includeProto = true, protoDefault = 'lbry://') {
|
||||||
streamClaimId,
|
streamClaimId,
|
||||||
channelName,
|
channelName,
|
||||||
channelClaimId,
|
channelClaimId,
|
||||||
primaryClaimSequence,
|
|
||||||
primaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
startTime
|
startTime
|
||||||
} = UrlObj,
|
} = UrlObj,
|
||||||
deprecatedParts = _objectWithoutProperties(UrlObj, ['streamName', 'streamClaimId', 'channelName', 'channelClaimId', 'primaryClaimSequence', 'primaryBidPosition', 'secondaryClaimSequence', 'secondaryBidPosition', 'startTime']);
|
deprecatedParts = _objectWithoutProperties(UrlObj, ['streamName', 'streamClaimId', 'channelName', 'channelClaimId', 'startTime']);
|
||||||
const { claimId, claimName, contentName } = deprecatedParts;
|
const { claimId, claimName, contentName } = deprecatedParts;
|
||||||
|
|
||||||
if (!claimName && !channelName && !streamName) {
|
if (!claimName && !channelName && !streamName) {
|
||||||
|
@ -1536,32 +1514,18 @@ function buildURI(UrlObj, includeProto = true, protoDefault = 'lbry://') {
|
||||||
return (includeProto ? protoDefault : '') +
|
return (includeProto ? protoDefault : '') +
|
||||||
// primaryClaimName will always exist here because we throw above if there is no "name" value passed in
|
// primaryClaimName will always exist here because we throw above if there is no "name" value passed in
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
primaryClaimName + (primaryClaimId ? `#${primaryClaimId}` : '') + (primaryClaimSequence ? `:${primaryClaimSequence}` : '') + (primaryBidPosition ? `${primaryBidPosition}` : '') + (secondaryClaimName ? `/${secondaryClaimName}` : '') + (secondaryClaimId ? `#${secondaryClaimId}` : '') + (secondaryClaimSequence ? `:${secondaryClaimSequence}` : '') + (secondaryBidPosition ? `${secondaryBidPosition}` : '') + (startTime ? `?t=${startTime}` : '');
|
primaryClaimName + (primaryClaimId ? `:${primaryClaimId}` : '') + (secondaryClaimName ? `/${secondaryClaimName}` : '') + (secondaryClaimId ? `:${secondaryClaimId}` : '') + (startTime ? `?t=${startTime}` : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Takes a parseable LBRY URL and converts it to standard, canonical format */
|
/* Takes a parseable LBRY URL and converts it to standard, canonical format */
|
||||||
function normalizeURI(URL) {
|
function normalizeURI(URL) {
|
||||||
const {
|
const { streamName, streamClaimId, channelName, channelClaimId, startTime } = parseURI(URL);
|
||||||
streamName,
|
|
||||||
streamClaimId,
|
|
||||||
channelName,
|
|
||||||
channelClaimId,
|
|
||||||
primaryClaimSequence,
|
|
||||||
primaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
startTime
|
|
||||||
} = parseURI(URL);
|
|
||||||
|
|
||||||
return buildURI({
|
return buildURI({
|
||||||
streamName,
|
streamName,
|
||||||
streamClaimId,
|
streamClaimId,
|
||||||
channelName,
|
channelName,
|
||||||
channelClaimId,
|
channelClaimId,
|
||||||
primaryClaimSequence,
|
|
||||||
primaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
startTime
|
startTime
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1592,25 +1556,12 @@ function isURIClaimable(URL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToShareLink(URL) {
|
function convertToShareLink(URL) {
|
||||||
const {
|
const { streamName, streamClaimId, channelName, channelClaimId } = parseURI(URL);
|
||||||
streamName,
|
|
||||||
streamClaimId,
|
|
||||||
channelName,
|
|
||||||
channelClaimId,
|
|
||||||
primaryBidPosition,
|
|
||||||
primaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
secondaryClaimSequence
|
|
||||||
} = parseURI(URL);
|
|
||||||
return buildURI({
|
return buildURI({
|
||||||
streamName,
|
streamName,
|
||||||
streamClaimId,
|
streamClaimId,
|
||||||
channelName,
|
channelName,
|
||||||
channelClaimId,
|
channelClaimId
|
||||||
primaryBidPosition,
|
|
||||||
primaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
secondaryClaimSequence
|
|
||||||
}, true, 'https://open.lbry.com/');
|
}, true, 'https://open.lbry.com/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3282,14 +3233,6 @@ const doCheckPendingTxs = () => (dispatch, getState) => {
|
||||||
}, 30000);
|
}, 30000);
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://github.com/reactjs/redux/issues/911
|
|
||||||
function batchActions(...actions) {
|
|
||||||
return {
|
|
||||||
type: 'BATCH_ACTIONS',
|
|
||||||
actions
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
function _asyncToGenerator$1(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
function _asyncToGenerator$1(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||||
|
@ -4052,7 +3995,7 @@ const selectFileListDownloadedSort = reselect.createSelector(selectState$2, stat
|
||||||
|
|
||||||
const selectDownloadedUris = reselect.createSelector(selectFileInfosDownloaded,
|
const selectDownloadedUris = reselect.createSelector(selectFileInfosDownloaded,
|
||||||
// We should use permament_url but it doesn't exist in file_list
|
// We should use permament_url but it doesn't exist in file_list
|
||||||
info => info.slice().map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`));
|
info => info.slice().map(claim => `lbry://${claim.claim_name}:${claim.claim_id}`));
|
||||||
|
|
||||||
const makeSelectMediaTypeForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), makeSelectContentTypeForUri(uri), (fileInfo, contentType) => {
|
const makeSelectMediaTypeForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), makeSelectContentTypeForUri(uri), (fileInfo, contentType) => {
|
||||||
if (!fileInfo && !contentType) {
|
if (!fileInfo && !contentType) {
|
||||||
|
@ -4297,6 +4240,14 @@ function doSetFileListSort(page, value) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/reactjs/redux/issues/911
|
||||||
|
function batchActions(...actions) {
|
||||||
|
return {
|
||||||
|
type: 'BATCH_ACTIONS',
|
||||||
|
actions
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
function _objectWithoutProperties$2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
function _objectWithoutProperties$2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||||
|
|
4
dist/flow-typed/lbryURI.js
vendored
4
dist/flow-typed/lbryURI.js
vendored
|
@ -8,10 +8,6 @@ declare type LbryUrlObj = {
|
||||||
streamClaimId?: string,
|
streamClaimId?: string,
|
||||||
channelName?: string,
|
channelName?: string,
|
||||||
channelClaimId?: string,
|
channelClaimId?: string,
|
||||||
primaryClaimSequence?: number,
|
|
||||||
secondaryClaimSequence?: number,
|
|
||||||
primaryBidPosition?: number,
|
|
||||||
secondaryBidPosition?: number,
|
|
||||||
startTime?: number,
|
startTime?: number,
|
||||||
|
|
||||||
// Below are considered deprecated and should not be used due to unreliableness with claim.canonical_url
|
// Below are considered deprecated and should not be used due to unreliableness with claim.canonical_url
|
||||||
|
|
4
flow-typed/lbryURI.js
vendored
4
flow-typed/lbryURI.js
vendored
|
@ -8,10 +8,6 @@ declare type LbryUrlObj = {
|
||||||
streamClaimId?: string,
|
streamClaimId?: string,
|
||||||
channelName?: string,
|
channelName?: string,
|
||||||
channelClaimId?: string,
|
channelClaimId?: string,
|
||||||
primaryClaimSequence?: number,
|
|
||||||
secondaryClaimSequence?: number,
|
|
||||||
primaryBidPosition?: number,
|
|
||||||
secondaryBidPosition?: number,
|
|
||||||
startTime?: number,
|
startTime?: number,
|
||||||
|
|
||||||
// Below are considered deprecated and should not be used due to unreliableness with claim.canonical_url
|
// Below are considered deprecated and should not be used due to unreliableness with claim.canonical_url
|
||||||
|
|
|
@ -4,11 +4,11 @@ const channelNameMinLength = 1;
|
||||||
const claimIdMaxLength = 40;
|
const claimIdMaxLength = 40;
|
||||||
|
|
||||||
// see https://spec.lbry.com/#urls
|
// see https://spec.lbry.com/#urls
|
||||||
export const regexInvalidURI = /[ =&#:$@%?;/\\"<>%\{\}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
export const regexInvalidURI = /[ =&#:$@%?;/\\"<>%{}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
||||||
export const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
export const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
||||||
const regexPartProtocol = '^((?:lbry://)?)';
|
const regexPartProtocol = '^((?:lbry://)?)';
|
||||||
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
||||||
const regexPartModifierSeparator = '([:$#]?)([^/]*)';
|
const regexPartModifierSeparator = '([:#]?)([^/]*)';
|
||||||
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
||||||
const separateQuerystring = new RegExp(queryStringBreaker);
|
const separateQuerystring = new RegExp(queryStringBreaker);
|
||||||
|
|
||||||
|
@ -23,10 +23,6 @@ const separateQuerystring = new RegExp(queryStringBreaker);
|
||||||
* - streamClaimId (string, if present)
|
* - streamClaimId (string, if present)
|
||||||
* - channelName (string, if present)
|
* - channelName (string, if present)
|
||||||
* - channelClaimId (string, if present)
|
* - channelClaimId (string, if present)
|
||||||
* - primaryClaimSequence (int, if present)
|
|
||||||
* - secondaryClaimSequence (int, if present)
|
|
||||||
* - primaryBidPosition (int, if present)
|
|
||||||
* - secondaryBidPosition (int, if present)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function parseURI(url: string, requireProto: boolean = false): LbryUrlObj {
|
export function parseURI(url: string, requireProto: boolean = false): LbryUrlObj {
|
||||||
|
@ -98,14 +94,8 @@ export function parseURI(url: string, requireProto: boolean = false): LbryUrlObj
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate and process modifier
|
// Validate and process modifier
|
||||||
const [primaryClaimId, primaryClaimSequence, primaryBidPosition] = parseURIModifier(
|
const [primaryClaimId] = parseURIModifier(primaryModSeparator, primaryModValue);
|
||||||
primaryModSeparator,
|
const [secondaryClaimId] = parseURIModifier(secondaryModSeparator, secondaryModValue);
|
||||||
primaryModValue
|
|
||||||
);
|
|
||||||
const [secondaryClaimId, secondaryClaimSequence, secondaryBidPosition] = parseURIModifier(
|
|
||||||
secondaryModSeparator,
|
|
||||||
secondaryModValue
|
|
||||||
);
|
|
||||||
const streamName = includesChannel ? possibleStreamName : streamNameOrChannelName;
|
const streamName = includesChannel ? possibleStreamName : streamNameOrChannelName;
|
||||||
const streamClaimId = includesChannel ? secondaryClaimId : primaryClaimId;
|
const streamClaimId = includesChannel ? secondaryClaimId : primaryClaimId;
|
||||||
const channelClaimId = includesChannel && primaryClaimId;
|
const channelClaimId = includesChannel && primaryClaimId;
|
||||||
|
@ -117,12 +107,6 @@ export function parseURI(url: string, requireProto: boolean = false): LbryUrlObj
|
||||||
...(streamClaimId ? { streamClaimId } : {}),
|
...(streamClaimId ? { streamClaimId } : {}),
|
||||||
...(channelName ? { channelName } : {}),
|
...(channelName ? { channelName } : {}),
|
||||||
...(channelClaimId ? { channelClaimId } : {}),
|
...(channelClaimId ? { channelClaimId } : {}),
|
||||||
...(primaryClaimSequence ? { primaryClaimSequence: parseInt(primaryClaimSequence, 10) } : {}),
|
|
||||||
...(secondaryClaimSequence
|
|
||||||
? { secondaryClaimSequence: parseInt(secondaryClaimSequence, 10) }
|
|
||||||
: {}),
|
|
||||||
...(primaryBidPosition ? { primaryBidPosition: parseInt(primaryBidPosition, 10) } : {}),
|
|
||||||
...(secondaryBidPosition ? { secondaryBidPosition: parseInt(secondaryBidPosition, 10) } : {}),
|
|
||||||
...(startTime ? { startTime: parseInt(startTime, 10) } : {}),
|
...(startTime ? { startTime: parseInt(startTime, 10) } : {}),
|
||||||
|
|
||||||
// The values below should not be used for new uses of parseURI
|
// The values below should not be used for new uses of parseURI
|
||||||
|
@ -136,20 +120,14 @@ export function parseURI(url: string, requireProto: boolean = false): LbryUrlObj
|
||||||
|
|
||||||
function parseURIModifier(modSeperator: ?string, modValue: ?string) {
|
function parseURIModifier(modSeperator: ?string, modValue: ?string) {
|
||||||
let claimId;
|
let claimId;
|
||||||
let claimSequence;
|
|
||||||
let bidPosition;
|
|
||||||
|
|
||||||
if (modSeperator) {
|
if (modSeperator) {
|
||||||
if (!modValue) {
|
if (!modValue) {
|
||||||
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modSeperator === '#') {
|
if (modSeperator === '#' || modSeperator === ':') {
|
||||||
claimId = modValue;
|
claimId = modValue;
|
||||||
} else if (modSeperator === ':') {
|
|
||||||
claimSequence = modValue;
|
|
||||||
} else if (modSeperator === '$') {
|
|
||||||
bidPosition = modValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,15 +135,7 @@ function parseURIModifier(modSeperator: ?string, modValue: ?string) {
|
||||||
throw new Error(__(`Invalid claim ID %claimId%.`, { claimId }));
|
throw new Error(__(`Invalid claim ID %claimId%.`, { claimId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {
|
return [claimId];
|
||||||
throw new Error(__('Claim sequence must be a number.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bidPosition && !bidPosition.match(/^-?[1-9][0-9]*$/)) {
|
|
||||||
throw new Error(__('Bid position must be a number.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return [claimId, claimSequence, bidPosition];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,10 +153,6 @@ export function buildURI(
|
||||||
streamClaimId,
|
streamClaimId,
|
||||||
channelName,
|
channelName,
|
||||||
channelClaimId,
|
channelClaimId,
|
||||||
primaryClaimSequence,
|
|
||||||
primaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
startTime,
|
startTime,
|
||||||
...deprecatedParts
|
...deprecatedParts
|
||||||
} = UrlObj;
|
} = UrlObj;
|
||||||
|
@ -231,40 +197,22 @@ export function buildURI(
|
||||||
// primaryClaimName will always exist here because we throw above if there is no "name" value passed in
|
// primaryClaimName will always exist here because we throw above if there is no "name" value passed in
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
primaryClaimName +
|
primaryClaimName +
|
||||||
(primaryClaimId ? `#${primaryClaimId}` : '') +
|
(primaryClaimId ? `:${primaryClaimId}` : '') +
|
||||||
(primaryClaimSequence ? `:${primaryClaimSequence}` : '') +
|
|
||||||
(primaryBidPosition ? `${primaryBidPosition}` : '') +
|
|
||||||
(secondaryClaimName ? `/${secondaryClaimName}` : '') +
|
(secondaryClaimName ? `/${secondaryClaimName}` : '') +
|
||||||
(secondaryClaimId ? `#${secondaryClaimId}` : '') +
|
(secondaryClaimId ? `:${secondaryClaimId}` : '') +
|
||||||
(secondaryClaimSequence ? `:${secondaryClaimSequence}` : '') +
|
|
||||||
(secondaryBidPosition ? `${secondaryBidPosition}` : '') +
|
|
||||||
(startTime ? `?t=${startTime}` : '')
|
(startTime ? `?t=${startTime}` : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Takes a parseable LBRY URL and converts it to standard, canonical format */
|
/* Takes a parseable LBRY URL and converts it to standard, canonical format */
|
||||||
export function normalizeURI(URL: string) {
|
export function normalizeURI(URL: string) {
|
||||||
const {
|
const { streamName, streamClaimId, channelName, channelClaimId, startTime } = parseURI(URL);
|
||||||
streamName,
|
|
||||||
streamClaimId,
|
|
||||||
channelName,
|
|
||||||
channelClaimId,
|
|
||||||
primaryClaimSequence,
|
|
||||||
primaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
startTime,
|
|
||||||
} = parseURI(URL);
|
|
||||||
|
|
||||||
return buildURI({
|
return buildURI({
|
||||||
streamName,
|
streamName,
|
||||||
streamClaimId,
|
streamClaimId,
|
||||||
channelName,
|
channelName,
|
||||||
channelClaimId,
|
channelClaimId,
|
||||||
primaryClaimSequence,
|
|
||||||
primaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
startTime,
|
startTime,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -295,26 +243,13 @@ export function isURIClaimable(URL: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertToShareLink(URL: string) {
|
export function convertToShareLink(URL: string) {
|
||||||
const {
|
const { streamName, streamClaimId, channelName, channelClaimId } = parseURI(URL);
|
||||||
streamName,
|
|
||||||
streamClaimId,
|
|
||||||
channelName,
|
|
||||||
channelClaimId,
|
|
||||||
primaryBidPosition,
|
|
||||||
primaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
} = parseURI(URL);
|
|
||||||
return buildURI(
|
return buildURI(
|
||||||
{
|
{
|
||||||
streamName,
|
streamName,
|
||||||
streamClaimId,
|
streamClaimId,
|
||||||
channelName,
|
channelName,
|
||||||
channelClaimId,
|
channelClaimId,
|
||||||
primaryBidPosition,
|
|
||||||
primaryClaimSequence,
|
|
||||||
secondaryBidPosition,
|
|
||||||
secondaryClaimSequence,
|
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
'https://open.lbry.com/'
|
'https://open.lbry.com/'
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
import { doFetchTxoPage } from 'redux/actions/wallet';
|
import { doFetchTxoPage } from 'redux/actions/wallet';
|
||||||
import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
|
import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
|
||||||
import { creditsToString } from 'util/format-credits';
|
import { creditsToString } from 'util/format-credits';
|
||||||
import { batchActions } from 'util/batch-actions';
|
|
||||||
import { createNormalizedClaimSearchKey } from 'util/claim';
|
import { createNormalizedClaimSearchKey } from 'util/claim';
|
||||||
import { PAGE_SIZE } from 'constants/claim';
|
import { PAGE_SIZE } from 'constants/claim';
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ export const selectFileListDownloadedSort = createSelector(
|
||||||
export const selectDownloadedUris = createSelector(
|
export const selectDownloadedUris = createSelector(
|
||||||
selectFileInfosDownloaded,
|
selectFileInfosDownloaded,
|
||||||
// We should use permament_url but it doesn't exist in file_list
|
// We should use permament_url but it doesn't exist in file_list
|
||||||
info => info.slice().map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`)
|
info => info.slice().map(claim => `lbry://${claim.claim_name}:${claim.claim_id}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectMediaTypeForUri = uri =>
|
export const makeSelectMediaTypeForUri = uri =>
|
||||||
|
@ -234,12 +234,12 @@ export const makeSelectSearchDownloadUrlsForPage = (query, page = 1) =>
|
||||||
|
|
||||||
return matchingFileInfos && matchingFileInfos.length
|
return matchingFileInfos && matchingFileInfos.length
|
||||||
? matchingFileInfos.slice(start, end).map(fileInfo =>
|
? matchingFileInfos.slice(start, end).map(fileInfo =>
|
||||||
buildURI({
|
buildURI({
|
||||||
streamName: fileInfo.claim_name,
|
streamName: fileInfo.claim_name,
|
||||||
channelName: fileInfo.channel_name,
|
channelName: fileInfo.channel_name,
|
||||||
channelClaimId: fileInfo.channel_claim_id,
|
channelClaimId: fileInfo.channel_claim_id,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue