Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always remove trailing slashes from report URL #375

Merged
merged 7 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
node-version: 18.x
- run: npm ci
working-directory: ./frontend
- run: npm run build
- run: npm run build -- --base=${{ vars.BOWTIE_BASE_URL || '/bowtie' }}
working-directory: ./frontend
- uses: actions/upload-artifact@v3
with:
Expand Down
15 changes: 14 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"react-bootstrap": "^2.8.0",
"react-bootstrap-icons": "^1.10.3",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.1"
"react-router-dom": "^6.14.1",
"urijs": "^1.19.11"
},
"devDependencies": {
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/urijs": "^1.19.19",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "8.43.0",
"eslint-plugin-react": "7.32.2",
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import { MainContainer } from "./MainContainer";
import { BowtieVersionContextProvider } from "./context/BowtieVersionContext";
import { DragAndDrop } from "./components/DragAndDrop/DragAndDrop";
import { parseReportData } from "./data/parseReportData";
import URI from "urijs";

const reportHost =
import.meta.env.MODE === "development"
? "https://bowtie.report"
: window.location.href;
const reportUri = new URI(reportHost).directory(import.meta.env.BASE_URL);

const reportUrl = "https://bowtie.report";
const titleTag = document.getElementsByTagName("title")[0];
const dialectToName = {
"draft2020-12": "Draft 2020-12",
Expand All @@ -24,7 +30,8 @@ const dialectToName = {
const fetchReportData = async (dialect) => {
const dialectName = dialectToName[dialect] ?? dialect;
titleTag.textContent = `Bowtie - ${dialectName}`;
const response = await fetch(`${reportUrl}/${dialect}.json`);
const url = reportUri.clone().filename(dialect).suffix("json").href();
const response = await fetch(url);
const jsonl = await response.text();
const lines = jsonl
.trim()
Expand Down