Skip to content

Commit 970bff6

Browse files
committed
[ReactNative] Enable resolveAssetSource for Image.android
1 parent d094952 commit 970bff6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Libraries/Image/__tests__/resolveAssetSource-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ describe('resolveAssetSource', () => {
3232
expect(resolveAssetSource(source2)).toBe(source2);
3333
});
3434

35+
it('ignores any weird data', () => {
36+
expect(resolveAssetSource(null)).toBe(null);
37+
expect(resolveAssetSource(42)).toBe(null);
38+
expect(resolveAssetSource('nonsense')).toBe(null);
39+
});
40+
3541
describe('bundle was loaded from network', () => {
3642
beforeEach(() => {
3743
SourceCode.scriptURL = 'http://10.0.0.1:8081/main.bundle';

Libraries/Image/resolveAssetSource.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ function pickScale(scales, deviceScale) {
4343
return scales[scales.length - 1] || 1;
4444
}
4545

46-
// TODO(frantic):
47-
// * Pick best scale and append @Nx to file path
48-
// * We are currently using httpServerLocation for both http and in-app bundle
4946
function resolveAssetSource(source) {
47+
if (!source || typeof source !== 'object') {
48+
return null;
49+
}
50+
5051
if (!source.__packager_asset) {
5152
return source;
5253
}

0 commit comments

Comments
 (0)