Skip to content

Commit 4674c9d

Browse files
committed
revert unused files and http support
1 parent 2bcbe98 commit 4674c9d

File tree

5 files changed

+18
-49
lines changed

5 files changed

+18
-49
lines changed

src/db/file/users.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
import fs from 'fs';
12
import Datastore from '@seald-io/nedb';
23

34
import { User, UserQuery } from '../types';
45

56
const COMPACTION_INTERVAL = 1000 * 60 * 60 * 24; // once per day
67

8+
// these don't get coverage in tests as they have already been run once before the test
9+
/* istanbul ignore if */
10+
if (!fs.existsSync('./.data')) fs.mkdirSync('./.data');
11+
/* istanbul ignore if */
12+
if (!fs.existsSync('./.data/db')) fs.mkdirSync('./.data/db');
13+
714
// export for testing purposes
815
export let db: Datastore;
916
if (process.env.NODE_ENV === 'test') {

src/proxy/processors/pre-processor/parseAction.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,16 @@ const exec = async (req: {
2626
const pathBreakdown = processUrlPath(req.originalUrl);
2727
let url = 'https:/' + (pathBreakdown?.repoPath ?? 'NOT-FOUND');
2828

29-
// First, try to find a matching repository by checking both http:// and https:// protocols
30-
const repoPath = pathBreakdown?.repoPath ?? 'NOT-FOUND';
31-
const httpsUrl = 'https:/' + repoPath;
32-
const httpUrl = 'http:/' + repoPath;
33-
34-
console.log(
35-
`Parse action trying HTTPS repo URL: ${httpsUrl} for inbound URL path: ${req.originalUrl}`,
36-
);
37-
38-
if (await db.getRepoByUrl(httpsUrl)) {
39-
url = httpsUrl;
40-
} else {
29+
console.log(`Parse action calculated repo URL: ${url} for inbound URL path: ${req.originalUrl}`);
30+
31+
if (!(await db.getRepoByUrl(url))) {
32+
// fallback for legacy proxy URLs
33+
// legacy git proxy paths took the form: https://<git proxy domain>:<port>/<repoPath>
34+
// by assuming the host was github.com
35+
url = 'https://github.com' + (pathBreakdown?.repoPath ?? 'NOT-FOUND');
4136
console.log(
42-
`Parse action trying HTTP repo URL: ${httpUrl} for inbound URL path: ${req.originalUrl}`,
37+
`Parse action fallback calculated repo URL: ${url} for inbound URL path: ${req.originalUrl}`,
4338
);
44-
if (await db.getRepoByUrl(httpUrl)) {
45-
url = httpUrl;
46-
} else {
47-
// fallback for legacy proxy URLs - try github.com with https
48-
url = 'https://github.com' + repoPath;
49-
console.log(
50-
`Parse action fallback calculated repo URL: ${url} for inbound URL path: ${req.originalUrl}`,
51-
);
52-
}
5339
}
5440

5541
return new Action(id.toString(), type, req.method, timestamp, url);

src/service/routes/repo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ const repo = (proxy: any) => {
163163
let newOrigin = true;
164164

165165
const existingHosts = await getAllProxiedHosts();
166-
existingHosts.forEach((host) => {
167-
// Check if the request URL contains this host
168-
if (req.body.url.includes(host)) {
166+
existingHosts.forEach((h) => {
167+
// assume SSL is in use and that our origins are missing the protocol
168+
if (req.body.url.startsWith(`https://${h}`)) {
169169
newOrigin = false;
170170
}
171171
});

src/ui/views/RepoList/repositories.types.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/ui/vite-env.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)