From c8b0d87054956e12a9b0ab1eff671e2dfe7ba1f0 Mon Sep 17 00:00:00 2001 From: aignatov-bio <47317017+aignatov-bio@users.noreply.github.com> Date: Tue, 9 Jul 2019 09:35:43 +0200 Subject: [PATCH] Fix global links in reports (#1894) --- app/services/reports/docx.rb | 5 +++++ app/services/reports/docx/private_methods.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/services/reports/docx.rb b/app/services/reports/docx.rb index fd9f0a573..ef668f4f5 100644 --- a/app/services/reports/docx.rb +++ b/app/services/reports/docx.rb @@ -35,6 +35,11 @@ class Reports::Docx end @docx end + + + def self.link_prepare(scinote_url, link) + link[0] == '/' ? scinote_url + link : link + end end # rubocop:enable Style/ClassAndModuleChildren diff --git a/app/services/reports/docx/private_methods.rb b/app/services/reports/docx/private_methods.rb index 31231e74b..392ee1714 100644 --- a/app/services/reports/docx/private_methods.rb +++ b/app/services/reports/docx/private_methods.rb @@ -39,7 +39,8 @@ module PrivateMethods br elsif text_el[:type] == 'a' if text_el[:link] - link text_el[:value], scinote_url + text_el[:link], link_style + link_url = Reports::Docx.link_prepare(scinote_url, text_el[:link]) + link text_el[:value], link_url, link_style else text text_el[:value], link_style end