Skip to content

Conversation

@Alanscut
Copy link
Contributor

fixing issue #2416 and #2396

var validateStatus = response.config.validateStatus;
if (!validateStatus || validateStatus(response.status)) {
var responseUrl = response.config.url;
if (!validateStatus || validateStatus(response.status) || (!response.status && ~responseUrl.indexOf('file:'))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tilde bitwise logic returns -1 when the string doesn't match and 0 when it matches, I believe it will always be false? unless I'm missing something

> myString = "test123"
"test123"
> ~myString.indexOf("test");
-1
> ~myString.indexOf("notpresent");
0

You can just do the normal .indexOf('file:') >= 0 or something similar

Copy link
Contributor Author

@Alanscut Alanscut Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, -1 is true rather than false...

var i = -1;
if (i) {
    console.log(i, " is true");
} else {
    console.log(i, " is false");
}

it will ouput: -1 ' is true'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ right

@yasuf
Copy link
Collaborator

yasuf commented Oct 25, 2019

and about the build, we're working on it, hopefully we have it passing soon

@Alanscut
Copy link
Contributor Author

Thanks @yasuf !

@Alanscut
Copy link
Contributor Author

Alanscut commented Nov 8, 2019

Hi @yasuf , since you have approved this PR, will you merge it?

@Alanscut Alanscut requested a review from chinesedfan March 11, 2020 01:53
@chinesedfan chinesedfan changed the title fix issue #2416, #2396--Getting local files (file://) fail Fixing getting local files (file://) failed Mar 12, 2020
@chinesedfan chinesedfan merged commit 885ada6 into axios:master Mar 23, 2020
@Alanscut Alanscut deleted the issue-1 branch March 24, 2020 03:21
@axios axios locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants