@ubiquity-os/plugin-sdk 3.12.0 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configuration.js +13 -5
- package/dist/configuration.mjs +13 -5
- package/package.json +1 -1
package/dist/configuration.js
CHANGED
|
@@ -175,6 +175,9 @@ function resolveManifestUrl(pluginUrl) {
|
|
|
175
175
|
while (pathname.endsWith("/") && pathname.length > 1) {
|
|
176
176
|
pathname = pathname.slice(0, -1);
|
|
177
177
|
}
|
|
178
|
+
if (pathname === "/") {
|
|
179
|
+
pathname = EMPTY_STRING;
|
|
180
|
+
}
|
|
178
181
|
if (pathname.endsWith(".json")) {
|
|
179
182
|
parsed.search = EMPTY_STRING;
|
|
180
183
|
parsed.hash = EMPTY_STRING;
|
|
@@ -610,10 +613,15 @@ var ConfigurationHandler = class {
|
|
|
610
613
|
return isGithubPlugin(plugin) ? this._fetchActionManifest(plugin) : this._fetchWorkerManifest(plugin);
|
|
611
614
|
}
|
|
612
615
|
async _fetchWorkerManifest(url) {
|
|
613
|
-
|
|
614
|
-
|
|
616
|
+
const manifestUrl = resolveManifestUrl(url);
|
|
617
|
+
if (!manifestUrl) {
|
|
618
|
+
this._logger.warn("Invalid plugin URL; cannot fetch manifest", { pluginUrl: url });
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
const manifestKey = `url:${manifestUrl}`;
|
|
622
|
+
if (this._manifestCache[manifestKey]) {
|
|
623
|
+
return this._manifestCache[manifestKey];
|
|
615
624
|
}
|
|
616
|
-
const manifestUrl = `${url}/manifest.json`;
|
|
617
625
|
try {
|
|
618
626
|
const result = await fetch(manifestUrl);
|
|
619
627
|
if (!result.ok) {
|
|
@@ -622,7 +630,7 @@ var ConfigurationHandler = class {
|
|
|
622
630
|
}
|
|
623
631
|
const jsonData = await result.json();
|
|
624
632
|
const manifest = this._decodeManifest(jsonData);
|
|
625
|
-
this._manifestCache[
|
|
633
|
+
this._manifestCache[manifestKey] = manifest;
|
|
626
634
|
return manifest;
|
|
627
635
|
} catch (e) {
|
|
628
636
|
this._logger.error("Could not find a manifest for Worker", { manifestUrl, err: e });
|
|
@@ -693,7 +701,7 @@ var ConfigurationHandler = class {
|
|
|
693
701
|
return manifest;
|
|
694
702
|
}
|
|
695
703
|
} catch (e) {
|
|
696
|
-
this._logger.warn(
|
|
704
|
+
this._logger.warn(`Could not find a valid manifest for ${owner}/${repo}${ref ? "@" + ref : ""}`, { owner, repo, ref, err: e });
|
|
697
705
|
}
|
|
698
706
|
return null;
|
|
699
707
|
})();
|
package/dist/configuration.mjs
CHANGED
|
@@ -136,6 +136,9 @@ function resolveManifestUrl(pluginUrl) {
|
|
|
136
136
|
while (pathname.endsWith("/") && pathname.length > 1) {
|
|
137
137
|
pathname = pathname.slice(0, -1);
|
|
138
138
|
}
|
|
139
|
+
if (pathname === "/") {
|
|
140
|
+
pathname = EMPTY_STRING;
|
|
141
|
+
}
|
|
139
142
|
if (pathname.endsWith(".json")) {
|
|
140
143
|
parsed.search = EMPTY_STRING;
|
|
141
144
|
parsed.hash = EMPTY_STRING;
|
|
@@ -571,10 +574,15 @@ var ConfigurationHandler = class {
|
|
|
571
574
|
return isGithubPlugin(plugin) ? this._fetchActionManifest(plugin) : this._fetchWorkerManifest(plugin);
|
|
572
575
|
}
|
|
573
576
|
async _fetchWorkerManifest(url) {
|
|
574
|
-
|
|
575
|
-
|
|
577
|
+
const manifestUrl = resolveManifestUrl(url);
|
|
578
|
+
if (!manifestUrl) {
|
|
579
|
+
this._logger.warn("Invalid plugin URL; cannot fetch manifest", { pluginUrl: url });
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
const manifestKey = `url:${manifestUrl}`;
|
|
583
|
+
if (this._manifestCache[manifestKey]) {
|
|
584
|
+
return this._manifestCache[manifestKey];
|
|
576
585
|
}
|
|
577
|
-
const manifestUrl = `${url}/manifest.json`;
|
|
578
586
|
try {
|
|
579
587
|
const result = await fetch(manifestUrl);
|
|
580
588
|
if (!result.ok) {
|
|
@@ -583,7 +591,7 @@ var ConfigurationHandler = class {
|
|
|
583
591
|
}
|
|
584
592
|
const jsonData = await result.json();
|
|
585
593
|
const manifest = this._decodeManifest(jsonData);
|
|
586
|
-
this._manifestCache[
|
|
594
|
+
this._manifestCache[manifestKey] = manifest;
|
|
587
595
|
return manifest;
|
|
588
596
|
} catch (e) {
|
|
589
597
|
this._logger.error("Could not find a manifest for Worker", { manifestUrl, err: e });
|
|
@@ -654,7 +662,7 @@ var ConfigurationHandler = class {
|
|
|
654
662
|
return manifest;
|
|
655
663
|
}
|
|
656
664
|
} catch (e) {
|
|
657
|
-
this._logger.warn(
|
|
665
|
+
this._logger.warn(`Could not find a valid manifest for ${owner}/${repo}${ref ? "@" + ref : ""}`, { owner, repo, ref, err: e });
|
|
658
666
|
}
|
|
659
667
|
return null;
|
|
660
668
|
})();
|