Skip to content

Commit

Permalink
Merge pull request #343 from Police-Data-Accessibility-Project/malfor…
Browse files Browse the repository at this point in the history
…med-url-bug-fix

Malformed url bug fix
  • Loading branch information
bonjarlow authored Jun 27, 2024
2 parents 3f36716 + f48a195 commit 6622599
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion client/src/components/SearchResultCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 2 additions & 0 deletions middleware/initialize_psycopg2_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() -> (
Expand All @@ -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(
Expand Down

0 comments on commit 6622599

Please sign in to comment.