#24 switched to absolute paths

relative paths won't necessarily work in css files
This commit is contained in:
Alok Saldanha
2020-08-16 16:17:28 -04:00
parent 486206bd32
commit 8cdd23a57b
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ class CacheEntry:
def rewrite_text_content(self, cellxgene_content):
# for v0.16.0 compatibility, see issue #24
gateway_content = re.sub('(="|\()/static/', r'\1static/', cellxgene_content).replace(
gateway_content = re.sub('(="|\()/static/', f'\\1{self.gateway_basepath()}static/', cellxgene_content).replace(
"http://fonts.gstatic.com", "https://fonts.gstatic.com"
).replace(self.cellxgene_basepath(), self.gateway_basepath())
return gateway_content
+5 -5
View File
@@ -2,15 +2,15 @@ import unittest
from cellxgene_gateway.cache_entry import CacheEntry
from cellxgene_gateway.cache_key import CacheKey
key = CacheKey('path/part', 'dataset', 'tmp.csv')
key = CacheKey('czi/pbmc3k.h5ad', 'pbmc3k.h5ad', 'tmp.csv')
class TestRenderEntry(unittest.TestCase):
def test_GIVEN_absolute_static_url_THEN_return_relative(self):
def test_GIVEN_absolute_static_url_THEN_include_path(self):
actual = CacheEntry.for_key(key, 8000).rewrite_text_content("src:url(/static/assets/")
expected = "src:url(static/assets/"
expected = "src:url(http://localhost:5005/view/czi/pbmc3k.h5ad/static/assets/"
self.assertEqual(actual, expected)
def test_GIVEN_absolute_src_THEN_return_relative(self):
def test_GIVEN_absolute_src_THEN_include_path(self):
actual = CacheEntry.for_key(key, 8000).rewrite_text_content('<link rel="shortcut icon" href="/static/assets/favicon.ico">')
expected = '<link rel="shortcut icon" href="static/assets/favicon.ico">'
expected = '<link rel="shortcut icon" href="http://localhost:5005/view/czi/pbmc3k.h5ad/static/assets/favicon.ico">'
self.assertEqual(actual, expected)