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

Generate wrong AssetURL #27134

Closed
djs66256 opened this issue Nov 6, 2019 · 2 comments
Closed

Generate wrong AssetURL #27134

djs66256 opened this issue Nov 6, 2019 · 2 comments
Labels
Bug Needs: Author Feedback Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@djs66256
Copy link

djs66256 commented Nov 6, 2019

Get an asset url like file://sdcard/bundle/assets/AwesomeModule/icon@2x.png, which is not standard file url format specified in rfc8089. It may miss a '/'.

In AssetSourceResolver.js

/**
   * Resolves to where the bundle is running from, with a scaled asset filename
   * E.g. 'file:///sdcard/bundle/assets/AwesomeModule/icon@2x.png'
   */
  scaledAssetURLNearBundle(): ResolvedAssetSource {
    const path = this.jsbundleUrl || 'file://';
    return this.fromSource(path + getScaledAssetPath(this.asset));
  }

But getScaledAssetPath return a path without beginning with '/'

/**
 * Returns a path like 'assets/AwesomeModule/icon@2x.png'
 */
function getScaledAssetPath(asset): string {
  const scale = AssetSourceResolver.pickScale(asset.scales, PixelRatio.get());
  const scaleSuffix = scale === 1 ? '' : '@' + scale + 'x';
  const assetDir = assetPathUtils.getBasePath(asset);
  return assetDir + '/' + asset.name + scaleSuffix + '.' + asset.type;
}

At last, we get an url like file://assets/AwesomeModule/icon@2x.png.

@djs66256 djs66256 added the Bug label Nov 6, 2019
@react-native-bot
Copy link
Collaborator

Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?

👉 Click here if you want to take another look at the Bug Report issue template.

@no-response
Copy link

no-response bot commented Mar 5, 2020

It's been three weeks since we asked for additional information from the author of this issue. As it happens, we don't have enough information to take action. We are going to close this issue, but please do not hesitate to open a new issue if you are still encountering this problem.

@no-response no-response bot closed this as completed Mar 5, 2020
@facebook facebook locked as resolved and limited conversation to collaborators Oct 2, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Needs: Author Feedback Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants