Skip to content

Commit

Permalink
Merge pull request #26855 from software-mansion-labs/ts-migration/try…
Browse files Browse the repository at this point in the history
…-resolve-url-from-api-root-lib

[No QA][TS migration] Migrate 'tryResolveUrlFromApiRoot.js' lib to TypeScript
  • Loading branch information
Julesssss authored Sep 13, 2023
2 parents a4672a3 + 5f7bada commit c76d447
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ const ORIGIN_PATTERN = new RegExp(`^(${ORIGINS_TO_REPLACE.join('|')})`);
* - Similarly for prod or staging URLs we replace the `https://www.expensify`
* or `https://staging.expensify` part, with `https://{API_ROOT}`
* - Unmatched URLs (non expensify) are returned with no modifications
*
* @param {String} url
* @returns {String}
*/
export default function tryResolveUrlFromApiRoot(url) {
function tryResolveUrlFromApiRoot(url: string): string;
function tryResolveUrlFromApiRoot(url: number): number;
function tryResolveUrlFromApiRoot(url: string | number): string | number {
// in native, when we import an image asset, it will have a number representation which can be used in `source` of Image
// in this case we can skip the url resolving
if (typeof url === 'number') {
Expand All @@ -28,3 +27,5 @@ export default function tryResolveUrlFromApiRoot(url) {
const apiRoot = ApiUtils.getApiRoot({shouldUseSecure: false});
return url.replace(ORIGIN_PATTERN, apiRoot);
}

export default tryResolveUrlFromApiRoot;

0 comments on commit c76d447

Please sign in to comment.