Support lbry:// links with timestamp
This commit is contained in:
parent
c30e1eee2c
commit
88d785a844
2 changed files with 9 additions and 1 deletions
1
flow-typed/lbryURI.js
vendored
1
flow-typed/lbryURI.js
vendored
|
@ -12,6 +12,7 @@ declare type LbryUrlObj = {
|
||||||
secondaryClaimSequence?: number,
|
secondaryClaimSequence?: number,
|
||||||
primaryBidPosition?: number,
|
primaryBidPosition?: number,
|
||||||
secondaryBidPosition?: number,
|
secondaryBidPosition?: 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
|
||||||
claimName?: string,
|
claimName?: string,
|
||||||
|
|
|
@ -60,6 +60,8 @@ export function parseURI(URL: string, requireProto: boolean = false): LbryUrlObj
|
||||||
secondaryModSeparator,
|
secondaryModSeparator,
|
||||||
secondaryModValue,
|
secondaryModValue,
|
||||||
] = rest;
|
] = rest;
|
||||||
|
const searchParams = new URLSearchParams(qs || '');
|
||||||
|
const startTime = searchParams.get('t');
|
||||||
|
|
||||||
// Validate protocol
|
// Validate protocol
|
||||||
if (requireProto && !proto) {
|
if (requireProto && !proto) {
|
||||||
|
@ -121,6 +123,7 @@ export function parseURI(URL: string, requireProto: boolean = false): LbryUrlObj
|
||||||
: {}),
|
: {}),
|
||||||
...(primaryBidPosition ? { primaryBidPosition: parseInt(primaryBidPosition, 10) } : {}),
|
...(primaryBidPosition ? { primaryBidPosition: parseInt(primaryBidPosition, 10) } : {}),
|
||||||
...(secondaryBidPosition ? { secondaryBidPosition: parseInt(secondaryBidPosition, 10) } : {}),
|
...(secondaryBidPosition ? { secondaryBidPosition: parseInt(secondaryBidPosition, 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
|
||||||
// They will not work properly with canonical_urls
|
// They will not work properly with canonical_urls
|
||||||
|
@ -184,6 +187,7 @@ export function buildURI(
|
||||||
primaryBidPosition,
|
primaryBidPosition,
|
||||||
secondaryClaimSequence,
|
secondaryClaimSequence,
|
||||||
secondaryBidPosition,
|
secondaryBidPosition,
|
||||||
|
startTime,
|
||||||
...deprecatedParts
|
...deprecatedParts
|
||||||
} = UrlObj;
|
} = UrlObj;
|
||||||
const { claimId, claimName, contentName } = deprecatedParts;
|
const { claimId, claimName, contentName } = deprecatedParts;
|
||||||
|
@ -233,7 +237,8 @@ export function buildURI(
|
||||||
(secondaryClaimName ? `/${secondaryClaimName}` : '') +
|
(secondaryClaimName ? `/${secondaryClaimName}` : '') +
|
||||||
(secondaryClaimId ? `#${secondaryClaimId}` : '') +
|
(secondaryClaimId ? `#${secondaryClaimId}` : '') +
|
||||||
(secondaryClaimSequence ? `:${secondaryClaimSequence}` : '') +
|
(secondaryClaimSequence ? `:${secondaryClaimSequence}` : '') +
|
||||||
(secondaryBidPosition ? `${secondaryBidPosition}` : '')
|
(secondaryBidPosition ? `${secondaryBidPosition}` : '') +
|
||||||
|
(startTime ? `?t=${startTime}` : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +253,7 @@ export function normalizeURI(URL: string) {
|
||||||
primaryBidPosition,
|
primaryBidPosition,
|
||||||
secondaryClaimSequence,
|
secondaryClaimSequence,
|
||||||
secondaryBidPosition,
|
secondaryBidPosition,
|
||||||
|
startTime,
|
||||||
} = parseURI(URL);
|
} = parseURI(URL);
|
||||||
|
|
||||||
return buildURI({
|
return buildURI({
|
||||||
|
@ -259,6 +265,7 @@ export function normalizeURI(URL: string) {
|
||||||
primaryBidPosition,
|
primaryBidPosition,
|
||||||
secondaryClaimSequence,
|
secondaryClaimSequence,
|
||||||
secondaryBidPosition,
|
secondaryBidPosition,
|
||||||
|
startTime,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue