Coder Social home page Coder Social logo

srcipt src strangeness about jsdom HOT 6 CLOSED

jsdom avatar jsdom commented on May 18, 2024
srcipt src strangeness

from jsdom.

Comments (6)

automatthew avatar automatthew commented on May 18, 2024

You'll want to tell jsdom the document location. Level can be left null:

jsdom.jsdom(slashDotContent, null, urlOfDoc).createWindow();

from jsdom.

tmpvar avatar tmpvar commented on May 18, 2024

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.

aflatter avatar aflatter commented on May 18, 2024

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.

aflatter avatar aflatter commented on May 18, 2024

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.

aflatter avatar aflatter commented on May 18, 2024

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.

tmpvar avatar tmpvar commented on May 18, 2024

this has been thoroughly tested here: https://github.com/tmpvar/jsdom/blob/master/test/jsdom/index.js#L403

from jsdom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.