Comments (6)
You'll want to tell jsdom the document location. Level can be left null:
jsdom.jsdom(slashDotContent, null, urlOfDoc).createWindow();
from jsdom.
I think the actual parsing of hrefs/srcs is not robust enough to handle this case. Initially I thought aa492e2 would fix this problem, but I believe it would simply produce a relative url in the case of a //domain.tld/path/to/resource
. Thank you for noticing this and submitting this issue. We'll address this shortly.
from jsdom.
I actually just worked on this because I had some problems with paths like '/foo.js' which have overriden the baseUrl. This has been fixed with: aflatter/jsdom@bc6de0b
Additionally the slashdot issue is fixed with: aflatter/jsdom@aa9de67
Reading the RFC, I don't really know if you can assume 'http' though.
An ugly test is at https://gist.github.com/feabb0152d953ed7ef51 - I was not sure where to expand your test suite.
from jsdom.
We just found out that my fix is actually wrong. Try the following snippet in your favorite browser from a https url:
y = document.createElement('a'); y.setAttribute('href', '//foo.com/bar'); y.href
=> "https://foo.com/bar"
Fix will follow :)
from jsdom.
Committed to my fork (https://github.com/aflatter/jsdom/tree/level2_resources).
Still, there are some questions. If we can not determine the base url it is not possible to determine the path for relative hrefs. We gotta think about how to handle these.
from jsdom.
this has been thoroughly tested here: https://github.com/tmpvar/jsdom/blob/master/test/jsdom/index.js#L403
from jsdom.
Related Issues (20)
- JSDOM fails in real-world environments like reddit, and youtube/rumble watch page
- `querySelector(":is([a],b):not(.c)")` throws a "not a valid selector" error HOT 1
- `runScripts: 'dangerously'` changes the output of `Object.getOwnPropertyNames(jsdom.window)`
- Feature request: when pretendToBeVisual is false, "requestAnimationFrame is not defined" should be a more informative error
- Raw parsing and serialization (HTML entities etc) HOT 2
- Cannot set an oklch background color with JavaScript
- Colon-Prefixed Classes Break :scope Selectors in querySelector/querySelectorAll
- Is there a way to deep clone a JSDOM object?
- Element's checkVisibility method not implemented in JSDOM
- Provide a `waitUntilComplete()` method to help testing frameworks detect pending tasks
- Any way to disable implied tags/auto closing tags? HOT 3
- `doc.write` is not working as browsers HOT 7
- `doc.write` is not working as browsers
- Unable to fetch <svg> and <g> tags using JSDOM library
- Font Awesome Kit: Error
- The script module will not retrieve the script from src and execute it HOT 1
- Bug: DOMException [SyntaxError]: 'h1,h2' is not a valid selector HOT 4
- jsdom behaves inconsistently with browser DOM in some cases
- TypeError when parsing `<constructor>` element
- Weird `Uint8Array` behaviour. Different classes? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsdom.