Skip to content

Commit

Permalink
Fix double slash in bucketBase
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm committed Sep 9, 2024
1 parent 117dc92 commit 9d7b2d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ui/src/hooks/useTimestampFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ if (!process.env.NEXT_PUBLIC_S3_BUCKET) {
}
const S3_BUCKET = process.env.NEXT_PUBLIC_S3_BUCKET;

const bucketBaseString = (bucket: string) =>
`https://${bucket}.s3.amazonaws.com/`;
const bucketBase = (bucket: string) => `https://${bucket}.s3.amazonaws.com`;

export const getHlsURI = (
bucket: string,
nodeName: string,
timestamp: number,
) => `${bucketBaseString(bucket)}/${nodeName}/hls/${timestamp}/live.m3u8`;
) => `${bucketBase(bucket)}/${nodeName}/hls/${timestamp}/live.m3u8`;

/**
* @typedef {Object} TimestampFetcherOptions
Expand All @@ -29,6 +28,7 @@ export const getHlsURI = (

/**
* Starts a timer that fetches the latest timestamp from a feed
* @param {string} bucket The bucket name of the node
* @param {string} nodeName The name of the feed to fetch from, as defined in the S3 bucket
* @param {TimestampFetcherOptions} options Callbacks for when the fetcher starts and stops
* @returns {TimestampFetcherResult} The latest timestamp, HLS URI, and AWS console URI
Expand All @@ -54,7 +54,7 @@ export function useTimestampFetcher(
let intervalId: NodeJS.Timeout | undefined;

const fetchTimestamp = (feed: string) => {
const timestampURI = `${bucketBaseString(bucket ?? S3_BUCKET)}/${feed}/latest.txt`;
const timestampURI = `${bucketBase(bucket ?? S3_BUCKET)}/${feed}/latest.txt`;

const xhr = new XMLHttpRequest();
currentXhr = xhr;
Expand Down

0 comments on commit 9d7b2d5

Please sign in to comment.