playcanvas / playcanvas/engine
Should asset.getFileUrl() return the full path?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
If I try to create a new asset:
var filename = assetName + '.glb';
var file = {
url: someAsset.getFileUrl(),
filename: filename
};
var asset = new pc.Asset(filename, 'container', file, null, options);
Where the url is a relative path (e.g '/foobar/bar.glb'), the asset loader will add a prefix (/api/) if in Editor. This causes an issue when the relative path is from an asset in the project (asset.getFileUrl()) and already has the prefix added.
When published, this is not an issue as there is no prefix.
url: window.location.origin + someAsset.getFileUrl();
Should getFileUrl return a full path instead so that there is a parity between the Editor and Published version of the game or check if the prefix is already added?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing asset.getFileUrl() and the asset loader's URL-prefix handling described in the issue. Reproduce the relative-path case in the Editor and in a published game, then define done as consistent URL resolution without duplicating the /api/ prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100