Skip to content

Commit

Permalink
[0.71] [Win32] Webpack assets do not prefix paths with /, which cause…
Browse files Browse the repository at this point in the history
…s a lost char in asset path (#12121)

* [Win32] Webpack assets do not prefix paths with /, which causes a lost char in asset path (#12119)

* Webpack assets do not prefix paths with /, which causes a lost char in asset path

* Change files

* lint:fix

* fix change file
  • Loading branch information
acoates-ms committed Sep 9, 2023
1 parent 7a2f766 commit 1811289
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Webpack assets do not prefix paths with /, which causes a lost char in asset path",
"packageName": "@office-iss/react-native-win32",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ class AssetResolverLateScaleResolution {
}

_getBasePath(local: boolean) {
let basePath = this._resolver.asset.httpServerLocation;
if (basePath[0] === '/') {
basePath = basePath.substr(1);
}

if (local) {
const safePath = this._resolver.asset.httpServerLocation
.substr(1)
.replace(/\.\.\//g, '_');
const safePath = basePath.replace(/\.\.\//g, '_');
// If this asset was created with the newer saveAssetPlugin, then we should shorten the path
// This conditional is added to allow back compat of older bundles which might have been created without the saveAssetPlugin
if (this._resolver.asset.__useShortPath) {
Expand All @@ -102,10 +105,6 @@ class AssetResolverLateScaleResolution {
return safePath;
}

let basePath = this._resolver.asset.httpServerLocation;
if (basePath[0] === '/') {
basePath = basePath.substr(1);
}
return basePath;
}

Expand Down

0 comments on commit 1811289

Please sign in to comment.