Skip to content

Commit 237ea63

Browse files
authored
Merge pull request danmactough#245 from danmactough/bug-152-relative-urls
Fix reresolve helper to correctly resolve relative URLs in RSS channel image
2 parents fd7d508 + f43b445 commit 237ea63

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

lib/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ function reresolve (node, baseurl) {
118118
if ('#' in level[el]) {
119119
level[el]['#'] = URL.resolve(baseurl, level[el]['#']);
120120
}
121+
} else if (el == 'image') {
122+
if ('url' in level[el] && level[el]['url'].constructor.name === 'Object' && '#' in level[el]['url']) {
123+
level[el]['url']['#'] = URL.resolve(baseurl, level[el]['url']['#']);
124+
}
125+
if ('link' in level[el] && level[el]['link'].constructor.name === 'Object' && '#' in level[el]['link']) {
126+
level[el]['link']['#'] = URL.resolve(baseurl, level[el]['link']['#']);
127+
}
121128
} else if ('@' in level[el]) {
122129
var attrs = Object.keys(level[el]['@']);
123130
attrs.forEach(function (name) {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0"?>
2+
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
3+
<channel>
4+
<title>Oracle VM VirtualBox: Ticket #10860: Full resolution not exposed to Linux guest</title>
5+
<link>https://www.virtualbox.org/ticket/10860</link>
6+
<description>&lt;p&gt;
7+
When using &lt;a class="wiki" href="https://www.virtualbox.org/wiki/VirtualBox"&gt;VirtualBox&lt;/a&gt; on a MacBook Pro Retina, only half the resolution is exposed to, at least, Linux guests. This causes the fonts to be blurry in the guest OS.
8+
&lt;/p&gt;
9+
&lt;p&gt;
10+
To verify this, install Linux, and go to fullscreen, type xrandr and notice the resolution is set to 1440x900.
11+
&lt;/p&gt;
12+
&lt;p&gt;
13+
To compare with VMWare, full Retina mode is supported: &lt;a class="ext-link" href="http://www.vmware.com/products/fusion/features.html#approved"&gt;&lt;span class="icon"&gt; &lt;/span&gt;http://www.vmware.com/products/fusion/features.html#approved&lt;/a&gt;
14+
&lt;/p&gt;
15+
&lt;p&gt;
16+
This exposes the current full resolution to the guest, which in the default host retina mode would mean the guest sees 2880x1800 resolution and has to deal with it on its own accordingly.
17+
&lt;/p&gt;
18+
</description>
19+
<language>en-us</language>
20+
<image>
21+
<title>Oracle VM VirtualBox</title>
22+
<url>/graphics/vbox_logo2_gradient.png</url>
23+
<link>https://www.virtualbox.org/ticket/10860</link>
24+
</image>
25+
<generator>Trac 0.12</generator>
26+
<item>
27+
28+
<dc:creator>dsvensson</dc:creator>
29+
30+
<pubDate>Fri, 24 Aug 2012 08:54:14 GMT</pubDate>
31+
<title></title>
32+
<link>https://www.virtualbox.org/ticket/10860#comment:1</link>
33+
<guid isPermaLink="false">https://www.virtualbox.org/ticket/10860#comment:1</guid>
34+
<description>
35+
&lt;p&gt;
36+
The &lt;a class="wiki" href="https://www.virtualbox.org/wiki/VirtualBox"&gt;VirtualBox&lt;/a&gt; version is actually the 4.2 beta but it couldn't be selected.
37+
&lt;/p&gt;
38+
</description>
39+
<category>Ticket</category>
40+
</item>
41+
</channel>
42+
</rss>

test/xmlbase.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ describe('xmlbase', function(){
1515
});
1616
});
1717

18+
it('should resolve relative image url in channel', function (done) {
19+
var feed = __dirname + '/feeds/relative-channel-image-url.xml';
20+
fs.createReadStream(feed).pipe(new FeedParser())
21+
.on('meta', function (meta) {
22+
assert.equal('https://www.virtualbox.org/graphics/vbox_logo2_gradient.png', meta.image.url);
23+
done();
24+
})
25+
.on('error', function (err) {
26+
assert.ifError(err);
27+
done(err);
28+
});
29+
});
30+
1831
it('should parse feedurl option and handle relative URIs with no root xml:base', function (done) {
1932
var feed = __dirname + '/feeds/intertwingly.atom';
2033
var options = { feedurl: 'http://intertwingly.net/blog/index.atom' };

0 commit comments

Comments
 (0)