From 79ca519ca3216e3866cd3b8154427e093ef4abd8 Mon Sep 17 00:00:00 2001 From: Robin Olsson Date: Thu, 22 Feb 2024 10:30:02 +0100 Subject: [PATCH] fix: handling underscore --- src/manifests/handlers/dash/segment.test.ts | 2 +- src/manifests/handlers/dash/segment.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/manifests/handlers/dash/segment.test.ts b/src/manifests/handlers/dash/segment.test.ts index 8fb3be1..16e4256 100644 --- a/src/manifests/handlers/dash/segment.test.ts +++ b/src/manifests/handlers/dash/segment.test.ts @@ -6,7 +6,7 @@ describe('dashSegmentHandler', () => { queryStringParameters: { url: 'https://stream.with_underscore.com/live-$RepresentationID$-$Time$.dash' }, - path: '/segment_82008145102133_audio_track_0_0_nor=128000_128000', + path: '/segment_82008145102133_123_audio_track_0_0_nor=128000_128000', requestContext: { elb: { targetGroupArn: '' } }, diff --git a/src/manifests/handlers/dash/segment.ts b/src/manifests/handlers/dash/segment.ts index b68cecb..20e435a 100644 --- a/src/manifests/handlers/dash/segment.ts +++ b/src/manifests/handlers/dash/segment.ts @@ -40,7 +40,7 @@ export default async function dashSegmentHandler( // eslint-disable-next-line prefer-const const [, reqSegmentIndexOrTimeStr, bitrateStr, ...representationIdStrList] = pathStem.split('_'); - let representationIdStr = representationIdStrList.join('-'); + const representationIdStr = representationIdStrList.join('_'); // Build correct Source Segment url // segment templates may contain a width parameter "$Number%0[width]d$", and then we need to zero-pad them to that length @@ -57,12 +57,6 @@ export default async function dashSegmentHandler( } const reqSegmentIndexInt = parseInt(reqSegmentIndexOrTimeStr); - const possibleId = pathStem.match( - /(audio|video)_track_\d+_\d+_[a-zA-Z]{3}=\d+_\d+/ - ); - if (possibleId) { - representationIdStr = possibleId[0]; - } // Replace RepresentationID in url if present if (representationIdStr) { segmentUrl = segmentUrl.replace(