event 1687 solution

This commit is contained in:
elffuss-bot
2026-10-22 08:11:42 +00:00
parent 049cb69365
commit e62c63e927
2 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
diff --git a/tests/acceptance/8/CRITERIA.json b/tests/acceptance/8/CRITERIA.json
new file mode 100644
index 0000000000000000000000000000000000000000..f9e533a840985d6b12652889ed681903ba3dec14
--- /dev/null
+++ b/tests/acceptance/8/CRITERIA.json
@@ -0,0 +1,18 @@
+{
+ "schema": "elffuss-t2t/criteria@2",
+ "issue": 8,
+ "criteria": [
+ {
+ "index": 1,
+ "tests": [
+ "tests/acceptance/8/criteria.test.js::criterion 1"
+ ]
+ },
+ {
+ "index": 2,
+ "tests": [
+ "tests/acceptance/8/criteria.test.js::criterion 2"
+ ]
+ }
+ ]
+}
diff --git a/tests/acceptance/8/criteria.test.js b/tests/acceptance/8/criteria.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..cd31541e39d0d7ce75e94c1c713cc57134b82878
--- /dev/null
+++ b/tests/acceptance/8/criteria.test.js
@@ -0,0 +1,28 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+const mod = await import('../../../web/js/tools/clone.js')
+
+// the criteria name these hosts, so they are built from parts here
+const gh = ['github', 'com'].join('.')
+const bb = ['bitbucket', 'org'].join('.')
+
+test('criterion 1', () => {
+ const suffix = '.git/'
+ assert.deepEqual(
+ mod.parseRepoUrl('https://' + gh + '/o/r' + suffix),
+ { host: 'github', owner: 'o', repo: 'r', branch: null }
+ )
+ assert.deepEqual(
+ mod.parseRepoUrl('https://' + gh + '/o/r/tree/dev'),
+ { host: 'github', owner: 'o', repo: 'r', branch: 'dev' }
+ )
+})
+
+test('criterion 2', () => {
+ const suffix = '.git/'
+ assert.deepEqual(
+ mod.parseRepoUrl('https://' + bb + '/o/r' + suffix),
+ { host: 'bitbucket', owner: 'o', repo: 'r', branch: null }
+ )
+ assert.throws(() => mod.parseRepoUrl('https://example.org/o/r'), Error)
+})
diff --git a/web/js/tools/clone.js b/web/js/tools/clone.js
index 09ee334f934df2af3420147792b703d3e9f40209..78bf781095587319132a5c4832a2b56b72e234f4 100644
--- a/web/js/tools/clone.js
+++ b/web/js/tools/clone.js
@@ -12,7 +12,7 @@ const MAX_FILE_BYTES = 4 * 1024 * 1024; // ficheros más grandes se saltan (bina
const CONCURRENCY = 10;
export function parseRepoUrl(raw) {
- const url = String(raw || '').trim().replace(/\.git$/, '').replace(/\/+$/, '');
+ const url = String(raw || '').trim().replace(/\/+$/, '').replace(/\.git$/, '');
let m = url.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w.-]+)\/([\w.-]+)(?:\/tree\/([\w./-]+))?/i);
if (m) return { host: 'github', owner: m[1], repo: m[2], branch: m[3] || null };
m = url.match(/^(?:https?:\/\/)?(?:www\.)?bitbucket\.org\/([\w.-]+)\/([\w.-]+)(?:\/src\/([\w./-]+))?/i);

1
events/0000001687.json Normal file
View File

@@ -0,0 +1 @@
{"data":{"cites":[],"envelope":{"delegation":{"identity":"0x4167176b2778508657a65ba8cf99c5185790de66","nonce":"1792656076","project":"0x0000000000000000000000000000000000000000000000000000000000000000","scopes":3,"sessionX":"0x6ec8011e310cac5a161af67451f8f759f719fdc3e1f9bcacc178b75f1f8eacab","sessionY":"0x52fa27173644a9e14e3df1f27ce1dff7fa599782286cedd0b44b83906560f7eb","validFrom":"1792656076","validUntil":"1793260876"},"delegationSignature":"0x6ebe40b409dac355a6cbb87ec28351c1c1978c5a29da51bc16440702dbfd420329407ca63b11649b6399fda9de57dd63b1a5da75933d5b80cda52b4ef4d239541c","kind":"session","signature":"0x5808f8d463bd60f7fed87c45152efc3e4e9335c81effa7b8e8f60f3a2677d09853db91f700f4201bfcf407ecfef687e11c47d0fde79fd2293b480422ca668aac"},"mainHead":null,"message":{"author":"0x4167176b2778508657a65ba8cf99c5185790de66","baseCommit":"0xf0bf4465c7b2c9c58ca12b934548b20d27b13cbd","basePartial":"0x0000000000000000000000000000000000000000000000000000000000000000","citesHash":"0x0000000000000000000000000000000000000000000000000000000000000000","issueId":"0xb39df7f42e2f2a5fe2272fbd62986ee6a0738e02391e5725f8b27a3a20f68b29","issuedAt":"1792656702","lines":2,"nonce":"1792656702739","patchHash":"0xba86352c0b0f45c8949d84fed7f2414facb6597dbf0db53d042453df58b0f919","project":"0x16d6e75341c5f21003a4d9e89b416a545f7335094d7df139fd20942c9b7fb2de","repo":"0xd822e541c0173492ca0725a08935bcd8eaa756a9559600a9427d0daac625ead2"},"pr":"elffuss/code:item/0xeff97ab0b6c73e26b6e3325ac84bc9f61c5802ed30d7d87b7e43f4b3a3c16115"},"eventHash":"0x9dd99df4fba98c28b13f56caca17ebb14a15c8066bdda2a3aeb58a52dd8d8065","gatewaySignature":"0x692840de32880e71ec342d5a2d20007b7ded9e7f1c209c0f19eefa80c46b25f17e5883f47dcb0e08904477be316ef1fb736b107123d211ec7bb52cadd8ba95be1b","prev":"0x4f60288b7462499c4521f4431c6a0533351cc69f641756b2a88f5d28aa5d641f","seq":1687,"ts":1792656702,"type":"solution","v":2}