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

Use LoadFile only if needed #14340

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/dev/core/src/Misc/fileTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const LoadImage = (
const fromBlob = url.substring(0, 5) === "blob:";
const fromData = url.substring(0, 5) === "data:";
const noOfflineSupport = () => {
if (fromBlob || fromData) {
if (fromBlob || fromData || !WebRequest.IsCustomRequestAvailable) {
img.src = url;
} else {
LoadFile(
Expand All @@ -293,7 +293,7 @@ export const LoadImage = (
undefined,
offlineProvider || undefined,
true,
(request, exception) => {
(_request, exception) => {
onErrorHandler(exception);
}
);
Expand Down
8 changes: 8 additions & 0 deletions packages/dev/core/src/Misc/webRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class WebRequest implements IWebRequest {

public static SkipRequestModificationForBabylonCDN = true;

/**
* This function can be called to check if there are request modifiers for network requests
* @returns true if there are any custom requests available
*/
public static get IsCustomRequestAvailable(): boolean {
return Object.keys(WebRequest.CustomRequestHeaders).length > 0 || WebRequest.CustomRequestModifiers.length > 0;
}

private _requestURL: string = "";

private _injectCustomRequestHeaders(): void {
Expand Down