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

suggestion to use str.indexOf(searchString) === 0 for better compatibility #1403

Closed
elasim opened this issue Nov 8, 2023 · 2 comments · Fixed by #1404
Closed

suggestion to use str.indexOf(searchString) === 0 for better compatibility #1403

elasim opened this issue Nov 8, 2023 · 2 comments · Fixed by #1404

Comments

@elasim
Copy link
Contributor

elasim commented Nov 8, 2023

According to caniuse, the browser coverage for the fetch API is similar to the support range for String.prototype.startsWith,
which suggests that browsers requiring a fetch polyfill would likely also need a polyfill for the startsWith API.

Therefore, it would be advisable to use str.indexOf(searchString) === 0 instead of startsWith in the code for better compatibility across browsers

image

fetch/fetch.js

Lines 544 to 550 in b5cee50

// This check if specifically for when a user fetches a file locally from the file system
// Only if the status is out of a normal range
if (request.url.startsWith('file://') && (xhr.status < 200 || xhr.status > 599)) {
options.status = 200;
} else {
options.status = xhr.status;
}

@JakeChampion
Copy link
Owner

I'll happily accept a pull request if you are up for submitting one

@vamshisuram
Copy link

@elasim Good point 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants