From 2033c59799059364107ffa0e349b483254739c1b Mon Sep 17 00:00:00 2001 From: bonjarlow Date: Thu, 27 Jun 2024 11:42:00 -0400 Subject: [PATCH 1/5] prepend https:// if not in source_url --- client/src/components/SearchResultCard.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/components/SearchResultCard.vue b/client/src/components/SearchResultCard.vue index d662c30e..6357de81 100644 --- a/client/src/components/SearchResultCard.vue +++ b/client/src/components/SearchResultCard.vue @@ -149,7 +149,11 @@ export default { this.$router.push(`/data-sources/${this.dataSource.airtable_uid}`); }, openSource() { - window.open(this.dataSource.source_url, '_blank'); + let url = this.dataSource.source_url; + if (!/^https?:\/\//i.test(url)) { + url = 'https://' + url; + } + window.open(url, '_blank'); }, formatDate: formatDateForSearchResults, }, From 99684aee0fa152eb4ea94b90dac3a62918fafd8e Mon Sep 17 00:00:00 2001 From: bonjarlow Date: Thu, 27 Jun 2024 11:42:30 -0400 Subject: [PATCH 2/5] explicitly load_env --- middleware/initialize_psycopg2_connection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/middleware/initialize_psycopg2_connection.py b/middleware/initialize_psycopg2_connection.py index 6b6e1966..367494e6 100644 --- a/middleware/initialize_psycopg2_connection.py +++ b/middleware/initialize_psycopg2_connection.py @@ -2,6 +2,7 @@ import os from psycopg2.extensions import connection as PgConnection from typing import Union, Dict, List +from dotenv import load_dotenv def initialize_psycopg2_connection() -> ( @@ -17,6 +18,7 @@ def initialize_psycopg2_connection() -> ( :return: A psycopg2 connection object if successful, or a dictionary with a count of 0 and an empty data list upon failure. """ try: + load_dotenv() DO_DATABASE_URL = os.getenv("DO_DATABASE_URL") return psycopg2.connect( From f5fe049144cc720ccb7068da94146813afe65f44 Mon Sep 17 00:00:00 2001 From: bonjarlow Date: Thu, 27 Jun 2024 16:54:30 -0400 Subject: [PATCH 3/5] extract regex to commented function --- client/src/components/SearchResultCard.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/components/SearchResultCard.vue b/client/src/components/SearchResultCard.vue index 6357de81..a267a563 100644 --- a/client/src/components/SearchResultCard.vue +++ b/client/src/components/SearchResultCard.vue @@ -150,10 +150,16 @@ export default { }, openSource() { let url = this.dataSource.source_url; + // ensure URL is treated as an absolute path + url = this.prepend_protocol_if_none(url) + window.open(url, '_blank'); + }, + prepend_protocol_if_none(url) { + // add 'https://' if the URL does not have a protocol if (!/^https?:\/\//i.test(url)) { - url = 'https://' + url; + return url = 'https://' + url; } - window.open(url, '_blank'); + return url; }, formatDate: formatDateForSearchResults, }, From 6cd4ad0026400c66dc794fc35d609511bb4bbc7c Mon Sep 17 00:00:00 2001 From: bonjarlow Date: Thu, 27 Jun 2024 16:59:36 -0400 Subject: [PATCH 4/5] space and tab mixing fixed --- client/src/components/SearchResultCard.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/components/SearchResultCard.vue b/client/src/components/SearchResultCard.vue index a267a563..3400210a 100644 --- a/client/src/components/SearchResultCard.vue +++ b/client/src/components/SearchResultCard.vue @@ -149,13 +149,13 @@ export default { this.$router.push(`/data-sources/${this.dataSource.airtable_uid}`); }, openSource() { - let url = this.dataSource.source_url; - // ensure URL is treated as an absolute path - url = this.prepend_protocol_if_none(url) + let url = this.dataSource.source_url; + // ensure URL is treated as an absolute path + url = this.prepend_protocol_if_none(url) window.open(url, '_blank'); }, - prepend_protocol_if_none(url) { - // add 'https://' if the URL does not have a protocol + prepend_protocol_if_none(url) { + // add 'https://' if the URL does not have a protocol if (!/^https?:\/\//i.test(url)) { return url = 'https://' + url; } From f48a195060ea2a5f3d85bde0d14c216e452225fe Mon Sep 17 00:00:00 2001 From: bonjarlow Date: Thu, 27 Jun 2024 17:02:37 -0400 Subject: [PATCH 5/5] space and tab mixing fixed... again --- client/src/components/SearchResultCard.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/SearchResultCard.vue b/client/src/components/SearchResultCard.vue index 3400210a..17ea31b6 100644 --- a/client/src/components/SearchResultCard.vue +++ b/client/src/components/SearchResultCard.vue @@ -149,7 +149,7 @@ export default { this.$router.push(`/data-sources/${this.dataSource.airtable_uid}`); }, openSource() { - let url = this.dataSource.source_url; + let url = this.dataSource.source_url; // ensure URL is treated as an absolute path url = this.prepend_protocol_if_none(url) window.open(url, '_blank');