diff --git a/client/src/components/SearchResultCard.vue b/client/src/components/SearchResultCard.vue index d662c30e..17ea31b6 100644 --- a/client/src/components/SearchResultCard.vue +++ b/client/src/components/SearchResultCard.vue @@ -149,7 +149,17 @@ 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; + // 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)) { + return url = 'https://' + url; + } + return url; }, formatDate: formatDateForSearchResults, }, 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(