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

Error when using with axios: "TypeError: Cannot read properties of undefined (reading 'charAt')" #259

Open
Jhon-Idrovo opened this issue Mar 3, 2024 · 1 comment

Comments

@Jhon-Idrovo
Copy link

When used with axios I'm finding this error:
Screenshot 2024-03-03 at 1 50 27 PM
I did the work of following the stack trace and found where is the problem. At line 41 in https://github.com/axios/axios/blob/v1.x/lib/helpers/isURLSameOrigin.js
Screenshot 2024-03-03 at 1 56 47 PM
Seems like Axios checks if the browser is a "standard" one by creating an element. The problem is that it expects that when you create an anchor element it sets itself the pathname property when you add the href property.

I tried setting the user agent to msie or trident but the issue is still showing up

@WebReflection
Copy link
Owner

There won't be any userAgent sniffing ever in this module and the issue seems to be on HTMLAnchorElement not providing the whole standard API: https://github.com/WebReflection/linkedom/blob/main/esm/html/anchor-element.js

I think your issue is bigger than charAt as most of your urlParsing.xxx expectations are broken ... but there is a proper API in Web standards that is URL that doesn't need DOM at all to work ... I am not keen to consider patches that workaround anything at all that diverges on MSIE detection as that's a defunct browser and for good so, eventually, all I can think in here that could happen is that somebody files a PR that adds accessors (getters only) methods to that prototype that simply forward the result of new URL(this.href).prototcol or host or search or pathname and call it a day, as that's not even part of the rendering pipe so it's acceptable as bloat nobody asked, or needed, to date.

Are you that person that would file that PR? 😉

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

No branches or pull requests

2 participants