-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rebroadcast: move url expansion into separate file
- Loading branch information
Showing
2 changed files
with
27 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sdk from '@scrypted/sdk'; | ||
|
||
export async function getUrlLocalAdresses(console: Console, url: string) { | ||
let urls: string[]; | ||
try { | ||
const addresses = await sdk.endpointManager.getLocalAddresses(); | ||
if (addresses) { | ||
const [address] = addresses; | ||
if (address) { | ||
const u = new URL(url); | ||
u.hostname = address; | ||
url = u.toString(); | ||
} | ||
urls = addresses.map(address => { | ||
const u = new URL(url); | ||
u.hostname = address; | ||
return u.toString(); | ||
}); | ||
} | ||
} | ||
catch (e) { | ||
console.warn('Error determining external addresses. Is Scrypted Server Address configured?', e); | ||
} | ||
return urls; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters