Skip to content

Commit

Permalink
Swap urllib for yarl; make use of process.env
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine Mazeas <[email protected]>
  • Loading branch information
karthanistyr committed Jan 9, 2020
1 parent 3b603a2 commit 3aadf0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion maubot/management/frontend/src/pages/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Main extends Component {

async getBasePath() {
try {
const resp = await fetch("./paths.json", {
const resp = await fetch(process.env.PUBLIC_URL + "/paths.json", {
headers: { "Content-Type": "application/json" }
})
const apiPathJson = await resp.json()
Expand Down
7 changes: 3 additions & 4 deletions maubot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
import asyncio
import json
from urllib.parse import urlparse
from yarl import URL

from aiohttp import web, hdrs
from aiohttp.abc import AbstractAccessLogger
Expand Down Expand Up @@ -136,9 +136,8 @@ def setup_static_root_files(self, directory: str, ui_base: str) -> None:
public_url = self.config["server.public_url"]
base_path = self.config["server.base_path"]
public_url_path = ""
if public_url != "":
url_parts = urlparse(public_url)
public_url_path = url_parts.path.rstrip("/")
if public_url:
public_url_path = URL(public_url).path.rstrip("/")

# assemble with base_path
api_path = f"{public_url_path}{base_path}"
Expand Down

0 comments on commit 3aadf0c

Please sign in to comment.