File tree 10 files changed +77
-3
lines changed 10 files changed +77
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ var handlers = require('./lib/handlers')
10
10
function toMDAST ( tree , options ) {
11
11
var settings = options || { }
12
12
13
+ h . baseFound = false
14
+ h . frozenBaseURL = null
15
+
13
16
h . handlers = xtend ( handlers , settings . handlers || { } )
14
17
h . augment = augment
15
18
h . document = settings . document
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ module . exports = base
4
+
5
+ function base ( h , node ) {
6
+ if ( ! h . baseFound ) {
7
+ h . frozenBaseURL = node . properties . href || null
8
+ h . baseFound = true
9
+ }
10
+ }
Original file line number Diff line number Diff line change 2
2
3
3
module . exports = image
4
4
5
+ var resolve = require ( '../util/resolve' )
6
+
5
7
function image ( h , node ) {
6
8
var props = {
7
- url : node . properties . src || '' ,
9
+ url : resolve ( h , node . properties . src ) ,
8
10
title : node . properties . title || null ,
9
11
alt : node . properties . alt || null
10
12
}
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ exports.command = ignore
19
19
exports . content = ignore
20
20
exports . datalist = ignore
21
21
exports . dialog = ignore
22
- exports . head = ignore
23
22
exports . input = ignore
24
23
exports . keygen = ignore
25
24
exports . link = ignore
@@ -28,6 +27,7 @@ exports.math = ignore
28
27
exports . menu = ignore
29
28
exports . menuitem = ignore
30
29
exports . meta = ignore
30
+ exports . noscript = ignore
31
31
exports . optgroup = ignore
32
32
exports . option = ignore
33
33
exports . script = ignore
@@ -79,6 +79,7 @@ exports.main = wrapped
79
79
exports . nav = wrapped
80
80
exports . section = wrapped
81
81
82
+ exports . base = require ( './base' )
82
83
exports . ol = exports . ul = exports . dir = require ( './list' )
83
84
exports . table = require ( './table' )
84
85
exports . tr = require ( './table-row' )
Original file line number Diff line number Diff line change 3
3
module . exports = link
4
4
5
5
var all = require ( '../all' )
6
+ var resolve = require ( '../util/resolve' )
6
7
7
8
function link ( h , node ) {
8
9
var props = {
9
- url : node . properties . href || '' ,
10
+ url : resolve ( h , node . properties . href ) ,
10
11
title : node . properties . title || null
11
12
}
12
13
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ module . exports = resolve
4
+
5
+ function resolve ( h , url ) {
6
+ if ( url === null || url === undefined ) {
7
+ return ''
8
+ }
9
+
10
+ return h . frozenBaseURL ? String ( new URL ( url , h . frozenBaseURL ) ) : url
11
+ }
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title > Document title</ title >
4
+ < base target ="_blank ">
5
+ < base href ="http://some-other-website.com ">
6
+ </ head >
7
+ < body >
8
+ < p > < a href ="http://some-other-url.com/relative.html "> example</ a > </ p >
9
+ < p > < a href ="relative.html "> example</ a > </ p >
10
+ < p > < a href ="./relative.html "> example</ a > </ p >
11
+ < p > < a href ="../relative.html "> example</ a > </ p >
12
+ < p > < a > example</ a > </ p >
13
+ </ body >
14
+ </ html >
Original file line number Diff line number Diff line change
1
+ [ example] ( http://some-other-url.com/relative.html )
2
+
3
+ [ example] ( relative.html )
4
+
5
+ [ example] ( ./relative.html )
6
+
7
+ [ example] ( ../relative.html )
8
+
9
+ [ example] ( < > )
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title > Document title</ title >
4
+ < base href ="http://example.com ">
5
+ < base href ="http://some-other-website.com ">
6
+ </ head >
7
+ < body >
8
+ < p > < a href ="http://some-other-url.com/relative.html "> example</ a > </ p >
9
+ < p > < a href ="relative.html "> example</ a > </ p >
10
+ < p > < a href ="./relative.html "> example</ a > </ p >
11
+ < p > < a href ="../relative.html "> example</ a > </ p >
12
+ < p > < a > example</ a > </ p >
13
+ </ body >
14
+ </ html >
Original file line number Diff line number Diff line change
1
+ [ example] ( http://some-other-url.com/relative.html )
2
+
3
+ [ example] ( http://example.com/relative.html )
4
+
5
+ [ example] ( http://example.com/relative.html )
6
+
7
+ [ example] ( http://example.com/relative.html )
8
+
9
+ [ example] ( < > )
You can’t perform that action at this time.
0 commit comments