Skip to content

Commit

Permalink
fix: support relative URLs in Location header
Browse files Browse the repository at this point in the history
  • Loading branch information
birme committed Jul 4, 2023
1 parent 6feb45a commit 6cb19d3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/adapters/WHEPAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ export class WHEPAdapter implements Adapter {
body: ''
});
if (response.ok) {
this.resource = response.headers.get('Location');
if (
response.headers.get('Location') &&
response.headers.get('Location')?.match(/^\//)
) {
const resourceUrl = new URL(
response.headers.get('Location')!,
this.channelUrl.origin
);
this.resource = resourceUrl.toString();
} else {
this.resource = response.headers.get('Location');
}
this.log('WHEP Resource', this.resource);
const offer = await response.text();
return offer;
Expand Down

0 comments on commit 6cb19d3

Please sign in to comment.