From 74aacd223dd79a1a269c7a191f859f415440a9ad Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 2 Mar 2023 16:39:01 +0100 Subject: [PATCH] fix(#186): use a different name for the hostname configuration --- public/script/app.js | 14 +++++++++----- src/anonymize-utils.ts | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/public/script/app.js b/public/script/app.js index eb913fc..9bb968a 100644 --- a/public/script/app.js +++ b/public/script/app.js @@ -416,20 +416,24 @@ angular scope: { file: "=" }, controller: function ($element, $scope, $http) { function renderNotebookJSON(json) { - $element.html(""); const notebook = nb.parse(json); try { - const rendered = notebook.render(); - $element.append(rendered); + $element.html(""); + $element.append(notebook.render()); Prism.highlightAll(); } catch (error) { $element.html("Unable to render the notebook."); } } function render() { - // $element.html(""); if ($scope.$parent.content) { - renderNotebookJSON(JSON.parse($scope.$parent.content)); + try { + renderNotebookJSON(JSON.parse($scope.$parent.content)); + } catch (error) { + $element.html( + "Unable to render the notebook invalid notebook format." + ); + } } else if ($scope.file) { $http .get($scope.file.download_url) diff --git a/src/anonymize-utils.ts b/src/anonymize-utils.ts index ea668b9..98cddeb 100644 --- a/src/anonymize-utils.ts +++ b/src/anonymize-utils.ts @@ -108,26 +108,26 @@ export function anonymizeContent( new RegExp( `https://github.com/${ repository.source.githubRepository.fullName - }/blob/${repository.source.branch?.name || "HEAD"}\\b`, + }/blob/${repository.source.branch?.name || "main"}\\b`, "gi" ), - `https://${config.HOSTNAME}/r/${repository.repoId}` + `https://${config.APP_HOSTNAME}/r/${repository.repoId}` ); content = content.replace( new RegExp( `https://github.com/${ repository.source.githubRepository.fullName - }/tree/${(repository.source as GitHubBase).branch?.name || "HEAD"}\\b`, + }/tree/${(repository.source as GitHubBase).branch?.name || "main"}\\b`, "gi" ), - `https://${config.HOSTNAME}/r/${repository.repoId}` + `https://${config.APP_HOSTNAME}/r/${repository.repoId}` ); content = content.replace( new RegExp( `https://github.com/${repository.source.githubRepository.fullName}`, "gi" ), - `https://${config.HOSTNAME}/r/${repository.repoId}` + `https://${config.APP_HOSTNAME}/r/${repository.repoId}` ); }