Skip to content

Commit

Permalink
Add CodeRabbit Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
gigincg committed Jan 11, 2025
1 parent d529316 commit aefaf37
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,20 @@ interface ParsedRemoteConfig {
}

function parseRemoteConfig(appConfig: string): ParsedRemoteConfig {
if (!appConfig.includes("/")) {
throw new Error(
`Invalid app configuration format: ${appConfig}. Expected 'org/repo' or 'org/repo@url'.`,
);
}
// Handle custom URLs (both localhost and custom hosted)
if (appConfig.includes("@")) {
const [package_, url] = appConfig.split("@");
const [org, repo] = package_.split("/");

if (!org || !repo || !url) {
throw new Error(
`Invalid custom URL configuration: ${appConfig}. Expected 'org/repo@url'.`,
);
}
// Add appropriate protocol based on whether it's localhost
const protocol = url.includes("localhost") ? "http://" : "https://";
const fullUrl = url.startsWith("http") ? url : `${protocol}${url}`;
Expand All @@ -90,6 +99,11 @@ function parseRemoteConfig(appConfig: string): ParsedRemoteConfig {

// Handle GitHub Pages URLs
const [org, repo] = appConfig.split("/");
if (!org || !repo) {
throw new Error(
`Invalid GitHub Pages configuration: ${appConfig}. Expected 'org/repo'.`,
);
}
return {
url: `https://${org}.github.io/${repo}/assets/remoteEntry.js`,
org,
Expand Down

0 comments on commit aefaf37

Please sign in to comment.