Skip to content

Commit

Permalink
Fix broken Quick Look URLs on yvsearch results
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Mar 26, 2023
1 parent 70651bf commit 34d65d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h2 class="chakra-heading bible-h3liox">Search results &#9786; »</h2>
<div class="chakra-stack bible-hrprkm">
<div class="bible-i7ebqk">
<h3 class="chakra-heading bible-dwzh7l">
<a class="chakra-link bible-1442mrf" href="/bible/111/rom.13.8">Romans 13:8 (NIV) &#9829;</a>
<a class="chakra-link bible-1442mrf" href="https://www.bible.com/bible/111/rom.13.8">Romans 13:8 (NIV) &#9829;</a>
</h3>
» &#9786;
<p class="chakra-text bible-16wqwvw">
Expand All @@ -16,7 +16,7 @@ <h3 class="chakra-heading bible-dwzh7l">
</div>
<div class="bible-i7ebqk">
<h3 class="chakra-heading bible-dwzh7l">
<a class="chakra-link bible-1442mrf" href="/bible/111/jhn.15.12">John 15:12 (NIV)</a>
<a class="chakra-link bible-1442mrf" href="https://www.bible.com/bible/111/jhn.15.12">John 15:12 (NIV)</a>
</h3>
<p class="chakra-text bible-16wqwvw">
<span class="content">consectetur <span class="highlighted">adipiscing</span> elit.</span>
Expand Down
4 changes: 2 additions & 2 deletions yvs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
PACKAGED_CODE_DIR_PATH = os.path.join(os.getcwd(), 'yvs')

# The template used to build the URL for a Bible reference
REF_URL_TEMPLATE = 'https://www.bible.com/bible/{ref}'
BASE_REF_URL = 'https://www.bible.com/bible/'


# Creates the directory (and any nonexistent parent directories) where this
Expand Down Expand Up @@ -260,7 +260,7 @@ def get_full_ref_name(ref):

# Builds the URL used to view the reference with the given UID
def get_ref_url(ref_uid):
return REF_URL_TEMPLATE.format(ref=ref_uid.upper())
return BASE_REF_URL + ref_uid.upper()


# Normalizes format of reference content by removing superfluous whitespace
Expand Down
7 changes: 4 additions & 3 deletions yvs/search_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import yvs.web as web
from yvs.yv_parser import YVParser

REF_URL_PREFIX = '/bible/'


# Parses unique reference identifier from the given reference URL
def get_uid_from_url(url):

return url.replace(REF_URL_PREFIX, '')
return (url
.replace(core.BASE_REF_URL, '')
# Handle case where origin may be absent from 'href' value
.replace(urllib.parse.urlparse(core.BASE_REF_URL).path, ''))


# Parser for search result HTML
Expand Down

0 comments on commit 34d65d8

Please sign in to comment.