diff --git a/src/test/test_tree7/[Content_Types].xml b/src/test/test_tree7/[Content_Types].xml
new file mode 100644
index 0000000..bb8704e
--- /dev/null
+++ b/src/test/test_tree7/[Content_Types].xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/test_tree7/word/_rels/document2.xml.rels b/src/test/test_tree7/word/_rels/document2.xml.rels
new file mode 100644
index 0000000..c303745
--- /dev/null
+++ b/src/test/test_tree7/word/_rels/document2.xml.rels
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/test_tree7/word/document2.xml b/src/test/test_tree7/word/document2.xml
new file mode 100644
index 0000000..ad6bc7e
--- /dev/null
+++ b/src/test/test_tree7/word/document2.xml
@@ -0,0 +1,305 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Testing 123
+
+
+
+
+
+
+
+
+
+
+
+
+ And some some more text
+
+
+
+
+
+ and then some
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Something here
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Blah
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ some
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ None
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some
+
+
+
+
+
+
+ some
+
+
+
+
+
+
+
+
+
+
+
+
+
+ some
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hello
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Here’s a hyperlink:
+
+
+
+
+
+
+
+ link
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ And here’s just some text:
+
+
+
+
+
+
+ www.example.com/a
+
+
+
+
+
+ www.example.com/a/b
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/xml_util.rs b/src/xml_util.rs
index fc705ed..2f3a04b 100644
--- a/src/xml_util.rs
+++ b/src/xml_util.rs
@@ -1210,6 +1210,36 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_replace_hyperlink2() -> io::Result<()> {
+ let orgdir = "./src/test/test_tree7";
+ let testdir = testdir!();
+
+ copy_dir_all(orgdir, &testdir)?;
+
+ let before_doc = fs::read_to_string("./src/test/test_tree7/word/document2.xml")?;
+ let before = fs::read_to_string("./src/test/test_tree7/word/_rels/document2.xml.rels")?;
+
+ assert!(before.contains("Target=\"http://www.example.com/a\""), "Precondition");
+ assert!(before_doc.contains(">www.example.com/a<"), "Precondition");
+ assert!(before.contains("Target=\"http://www.example.com/a/b\""), "Precondition");
+ assert!(before_doc.contains(">www.example.com/a/b<"), "Precondition");
+
+ XMLUtil::replace_rel_attr(&testdir.to_string_lossy(), "my-source.docx",
+ "www.example.com/a$", "www.example.com/a/",
+ &Some(&testdir.join("output-2.docx").to_string_lossy()));
+
+ let after_doc = fs::read_to_string(testdir.join("word/document2.xml"))?;
+ let after = fs::read_to_string(testdir.join("word/_rels/document2.xml.rels"))?;
+
+ assert!(after.contains("Target=\"http://www.example.com/a/\""));
+ assert!(after_doc.contains(">www.example.com/a<"), "Should not have changed the document text");
+ assert!(after.contains("Target=\"http://www.example.com/a/b\""), "Should not have changed this link");
+ assert!(after_doc.contains(">www.example.com/a/b<"), "Should not have changed the document text");
+
+ Ok(())
+ }
+
#[test]
fn test_replace_both() -> io::Result<()> {
let orgdir = "./src/test/test_tree3";