vite-plugin-caddy-multiple-tls 1.8.0 → 1.8.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/index.js +19 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,6 +33,16 @@ function isRecord(value) {
|
|
|
33
33
|
function normalizeRouteOwnershipDomains(domains) {
|
|
34
34
|
return Array.from(new Set(domains)).sort();
|
|
35
35
|
}
|
|
36
|
+
function haveSameDomains(left, right) {
|
|
37
|
+
if (left.length !== right.length) return false;
|
|
38
|
+
return left.every((domain, index) => domain === right[index]);
|
|
39
|
+
}
|
|
40
|
+
function getRouteOwnershipProjectRoot(record) {
|
|
41
|
+
return record.configRoot ?? record.cwd;
|
|
42
|
+
}
|
|
43
|
+
function canReclaimLiveOwnership(currentRecord, existingRecord) {
|
|
44
|
+
return getRouteOwnershipProjectRoot(currentRecord) === getRouteOwnershipProjectRoot(existingRecord) && haveSameDomains(currentRecord.domains, existingRecord.domains);
|
|
45
|
+
}
|
|
36
46
|
function getRouteOwnershipDirectory() {
|
|
37
47
|
return path.join(os.tmpdir(), "vite-plugin-caddy-multiple-tls", "owners");
|
|
38
48
|
}
|
|
@@ -294,8 +304,14 @@ async function claimRouteOwnership(record) {
|
|
|
294
304
|
return candidate.ownerId !== normalizedRecord.ownerId && intersectsDomains(candidate.domains, normalizedRecord.domains);
|
|
295
305
|
}
|
|
296
306
|
);
|
|
307
|
+
const reclaimableRecords = overlappingRecords.filter((candidate) => {
|
|
308
|
+
if (!isRouteOwnershipActive(candidate)) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
return canReclaimLiveOwnership(normalizedRecord, candidate);
|
|
312
|
+
});
|
|
297
313
|
const activeConflict = overlappingRecords.find((candidate) => {
|
|
298
|
-
return isRouteOwnershipActive(candidate);
|
|
314
|
+
return isRouteOwnershipActive(candidate) && !canReclaimLiveOwnership(normalizedRecord, candidate);
|
|
299
315
|
});
|
|
300
316
|
if (activeConflict) {
|
|
301
317
|
claimResult = {
|
|
@@ -306,11 +322,11 @@ async function claimRouteOwnership(record) {
|
|
|
306
322
|
return;
|
|
307
323
|
}
|
|
308
324
|
await writeRouteOwnership(normalizedRecord);
|
|
309
|
-
if (
|
|
325
|
+
if (reclaimableRecords.length > 0) {
|
|
310
326
|
claimResult = {
|
|
311
327
|
status: "reclaimed",
|
|
312
328
|
currentRecord: normalizedRecord,
|
|
313
|
-
previousRecords:
|
|
329
|
+
previousRecords: reclaimableRecords
|
|
314
330
|
};
|
|
315
331
|
return;
|
|
316
332
|
}
|