From d8e21c97e2efcc6ffbfdc294119545b58b538cd0 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 31 Aug 2023 14:41:34 -0300 Subject: [PATCH] fix: solo vincular urls que tienen protocolo --- app/controllers/build_stats_controller.rb | 7 ++++++- app/jobs/deploy_job.rb | 6 +++++- app/mailers/deploy_mailer.rb | 2 +- app/views/build_stats/index.haml | 2 +- app/views/deploy_mailer/deployed.html.haml | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/build_stats_controller.rb b/app/controllers/build_stats_controller.rb index 31a4c5d6..6961cf45 100644 --- a/app/controllers/build_stats_controller.rb +++ b/app/controllers/build_stats_controller.rb @@ -22,7 +22,12 @@ class BuildStatsController < ApplicationController @table = site.deployment_list.map do |deploy| type = deploy.class.name.underscore - urls = deploy.respond_to?(:urls) ? deploy.urls : [deploy.url].compact + urls = (deploy.respond_to?(:urls) ? deploy.urls : [deploy.url].compact).map do |url| + URI.parse(url) + rescue URI::Error + nil + end.compact + urls = [nil] if urls.empty? build_stat = deploy.build_stats.where(status: true).last seconds = build_stat&.seconds || 0 diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index a5cda360..6f486f29 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -51,7 +51,11 @@ class DeployJob < ApplicationJob status = d.deploy(output: @output) seconds = d.build_stats.last.try(:seconds) || 0 size = d.size - urls = d.respond_to?(:urls) ? d.urls : [d.url].compact + urls = (d.respond_to?(:urls) ? d.urls : [d.url].compact).map do |url| + URI.parse url + rescue URI::Error + nil + end.compact rescue StandardError => e status = false seconds ||= 0 diff --git a/app/mailers/deploy_mailer.rb b/app/mailers/deploy_mailer.rb index b7b464cb..37748b42 100644 --- a/app/mailers/deploy_mailer.rb +++ b/app/mailers/deploy_mailer.rb @@ -52,7 +52,7 @@ class DeployMailer < ApplicationMailer t << (row.map do |k, v| case k when :seconds then v[:human] - when :urls then url + when :urls then url.to_s else v end end) diff --git a/app/views/build_stats/index.haml b/app/views/build_stats/index.haml index 27c063f9..0b0e7755 100644 --- a/app/views/build_stats/index.haml +++ b/app/views/build_stats/index.haml @@ -14,7 +14,7 @@ - row[:urls].each do |url| %tr %th{ scope: 'row' }= row[:title] - %td= link_to_if url.present?, url, url, class: 'word-break-all' + %td= link_to_if (url.present? && uri.scheme.present?), url.to_s, url.to_s, class: 'word-break-all' %td %time{ datetime: row[:seconds][:machine] }= row[:seconds][:human] %td= row[:size] diff --git a/app/views/deploy_mailer/deployed.html.haml b/app/views/deploy_mailer/deployed.html.haml index f5afe5de..b3463db6 100644 --- a/app/views/deploy_mailer/deployed.html.haml +++ b/app/views/deploy_mailer/deployed.html.haml @@ -13,7 +13,7 @@ %tr %td= row[:title] %td= row[:status] - %td= link_to_if url.present?, url, url + %td= link_to_if (url.present? && uri.scheme.present?), url.to_s, url.to_s %td %time{ datetime: row[:seconds][:machine] }= row[:seconds][:human] %td= row[:size]