diff --git a/README.md b/README.md index c80edb4..98e16e8 100644 --- a/README.md +++ b/README.md @@ -27,22 +27,25 @@ Here is an example usage of **ziba.js**: Notice that the href now has the value of the title of the ziba-link

- once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE + once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE

- once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE + once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE

- once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE + once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE

- once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE + once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE

- once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE + once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE

- once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE + once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE +

+

+ >once Twice tHRICE FOURCE should become once Twice tHRICE FOURCE

ziba-link is designed to work for only local links. @@ -64,8 +67,9 @@ Here is an example usage of **ziba.js**: * `` — used for local links. * attributes: - * `title` - * `tramsform` + * `dir` + * `name` + * `transform` ## Import diff --git a/ziba.js b/ziba.js index b8eef95..759e1b4 100644 --- a/ziba.js +++ b/ziba.js @@ -99,7 +99,15 @@ function transform_link(rootElement) { } } - const href = "./"+ref + let dir = element.getAttribute("dir") + + let href = "./" + if ('string' === typeof dir && "" !== dir) { + href += dir + href += "/" + } + href += ref + anchor.setAttribute("href", href) element.replaceWith(anchor) diff --git a/ziba_test.js b/ziba_test.js index a8d24b2..5b21a6b 100644 --- a/ziba_test.js +++ b/ziba_test.js @@ -108,6 +108,10 @@ function testTransform() { html:'apple Banana CHERRY', expected:'apple Banana CHERRY', }, + { + html:'apple Banana CHERRY', + expected:'apple Banana CHERRY', + }, @@ -143,6 +147,10 @@ function testTransform() { html:'apple Banana CHERRY', expected:'apple Banana CHERRY', }, + { + html:'apple Banana CHERRY', + expected:'apple Banana CHERRY', + }, @@ -178,6 +186,10 @@ function testTransform() { html:'apple Banana CHERRY', expected:'apple Banana CHERRY', }, + { + html:'apple Banana CHERRY', + expected:'apple Banana CHERRY', + }, @@ -213,6 +225,10 @@ function testTransform() { html:'apple Banana CHERRY', expected:'apple Banana CHERRY', }, + { + html:'apple Banana CHERRY', + expected:'apple Banana CHERRY', + }, @@ -248,6 +264,10 @@ function testTransform() { html:'apple Banana CHERRY', expected:'apple Banana CHERRY', }, + { + html:'apple Banana CHERRY', + expected:'apple Banana CHERRY', + }, @@ -283,6 +303,10 @@ function testTransform() { html:'apple Banana CHERRY', expected:'apple Banana CHERRY', }, + { + html:'apple Banana CHERRY', + expected:'apple Banana CHERRY', + }, ] tests.forEach(function(test, testNumber){