Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA][TS migration] Migrate 'tryResolveUrlFromApiRoot.js' lib to TypeScript #26855

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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});
BartoszGrajdek marked this conversation as resolved.
Show resolved Hide resolved
return url.replace(ORIGIN_PATTERN, apiRoot);
}

export default tryResolveUrlFromApiRoot;
Loading