From 9fb8d3ea4e283e438d102d68939df971e0f21a95 Mon Sep 17 00:00:00 2001 From: shawn Date: Tue, 13 Oct 2026 09:23:10 +0800 Subject: [PATCH 1/4] chore: upgrade github actions and fix workflow warnings --- .github/workflows/ci.yml | 12 +++++++----- .github/workflows/docs.yml | 6 +++--- .github/workflows/release.yml | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb630d..e38029d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,13 +16,13 @@ on: jobs: docs: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@v7 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 + - uses: pnpm/action-setup@v6.1.0 + - uses: actions/setup-node@v7 with: - node-version: '22' + node-version: '24' cache: pnpm - run: pnpm install --frozen-lockfile - run: pnpm docs:build @@ -30,12 +30,13 @@ jobs: DOCS_BASE: /LocalShare server: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@v7 - uses: actions/setup-go@v7 with: go-version: '1.23' + cache-dependency-path: server/go.mod - name: 测试 LocalShare Server working-directory: server run: | @@ -49,6 +50,7 @@ jobs: - uses: actions/setup-go@v7 with: go-version: '1.23' + cache-dependency-path: server/go.mod - name: 编译 debug(首次会拉取 Swifter / Sparkle) run: swift build diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6c20ef7..38f856e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,11 +17,11 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@v7 - - uses: pnpm/action-setup@v6 + - uses: pnpm/action-setup@v6.1.0 - uses: actions/setup-node@v7 with: @@ -50,7 +50,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} needs: build - runs-on: ubuntu-latest + runs-on: ubuntu-26.04 steps: - name: Deploy to GitHub Pages id: deployment diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8060378..510774f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,7 @@ jobs: if: ${{ hashFiles('server/go.mod') != '' }} with: go-version-file: server/go.mod + cache-dependency-path: server/go.mod - name: 编译 LocalShare Server(Linux amd64 / arm64) if: ${{ hashFiles('server/go.mod') != '' }} From 73038d0bd6923a1c5f9354ee75a883bbf7c2842d Mon Sep 17 00:00:00 2001 From: shawn Date: Tue, 13 Oct 2026 09:32:11 +0800 Subject: [PATCH 2/4] fix: patch vulnerable documentation dependencies --- package.json | 3 + pnpm-lock.yaml | 350 ++++++++++++++++++++++++++++++------------------- 2 files changed, 216 insertions(+), 137 deletions(-) diff --git a/package.json b/package.json index f0e0a47..fc7b6ea 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,9 @@ "vitepress": "1.6.4" }, "pnpm": { + "overrides": { + "vite": "6.4.3" + }, "onlyBuiltDependencies": [ "esbuild" ] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 89efe7b..1b739ce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + vite: 6.4.3 + importers: .: @@ -130,141 +133,159 @@ packages: search-insights: optional: true - '@esbuild/aix-ppc64@0.21.5': - resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} - engines: {node: '>=12'} + '@esbuild/aix-ppc64@0.25.12': + resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} + engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.21.5': - resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==} - engines: {node: '>=12'} + '@esbuild/android-arm64@0.25.12': + resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} + engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.21.5': - resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==} - engines: {node: '>=12'} + '@esbuild/android-arm@0.25.12': + resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} + engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.21.5': - resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==} - engines: {node: '>=12'} + '@esbuild/android-x64@0.25.12': + resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} + engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.21.5': - resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==} - engines: {node: '>=12'} + '@esbuild/darwin-arm64@0.25.12': + resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} + engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.21.5': - resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} - engines: {node: '>=12'} + '@esbuild/darwin-x64@0.25.12': + resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} + engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.21.5': - resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==} - engines: {node: '>=12'} + '@esbuild/freebsd-arm64@0.25.12': + resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} + engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.21.5': - resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==} - engines: {node: '>=12'} + '@esbuild/freebsd-x64@0.25.12': + resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} + engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.21.5': - resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==} - engines: {node: '>=12'} + '@esbuild/linux-arm64@0.25.12': + resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} + engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.21.5': - resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==} - engines: {node: '>=12'} + '@esbuild/linux-arm@0.25.12': + resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} + engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.21.5': - resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==} - engines: {node: '>=12'} + '@esbuild/linux-ia32@0.25.12': + resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} + engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.21.5': - resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==} - engines: {node: '>=12'} + '@esbuild/linux-loong64@0.25.12': + resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} + engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.21.5': - resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==} - engines: {node: '>=12'} + '@esbuild/linux-mips64el@0.25.12': + resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} + engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.21.5': - resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==} - engines: {node: '>=12'} + '@esbuild/linux-ppc64@0.25.12': + resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} + engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.21.5': - resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==} - engines: {node: '>=12'} + '@esbuild/linux-riscv64@0.25.12': + resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} + engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.21.5': - resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==} - engines: {node: '>=12'} + '@esbuild/linux-s390x@0.25.12': + resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} + engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.21.5': - resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==} - engines: {node: '>=12'} + '@esbuild/linux-x64@0.25.12': + resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} + engines: {node: '>=18'} cpu: [x64] os: [linux] - '@esbuild/netbsd-x64@0.21.5': - resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==} - engines: {node: '>=12'} + '@esbuild/netbsd-arm64@0.25.12': + resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.12': + resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} + engines: {node: '>=18'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-x64@0.21.5': - resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==} - engines: {node: '>=12'} + '@esbuild/openbsd-arm64@0.25.12': + resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.12': + resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} + engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/sunos-x64@0.21.5': - resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==} - engines: {node: '>=12'} + '@esbuild/openharmony-arm64@0.25.12': + resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.25.12': + resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} + engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.21.5': - resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==} - engines: {node: '>=12'} + '@esbuild/win32-arm64@0.25.12': + resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} + engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.21.5': - resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==} - engines: {node: '>=12'} + '@esbuild/win32-ia32@0.25.12': + resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} + engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.21.5': - resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==} - engines: {node: '>=12'} + '@esbuild/win32-x64@0.25.12': + resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} + engines: {node: '>=18'} cpu: [x64] os: [win32] @@ -477,7 +498,7 @@ packages: resolution: {integrity: sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==} engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: - vite: ^5.0.0 || ^6.0.0 + vite: 6.4.3 vue: ^3.2.25 '@vue/compiler-core@3.5.42': @@ -606,14 +627,23 @@ packages: resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==} engines: {node: '>=0.12'} - esbuild@0.21.5: - resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==} - engines: {node: '>=12'} + esbuild@0.25.12: + resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} + engines: {node: '>=18'} hasBin: true estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + focus-trap@7.8.0: resolution: {integrity: sha512-/yNdlIkpWbM0ptxno3ONTuf+2g318kh2ez3KSeZN5dZ8YC6AAmgeWz+GasYYiBJPFaYcSAPeu4GfhUaChzIJXA==} @@ -678,6 +708,10 @@ packages: picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + postcss@8.5.26: resolution: {integrity: sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==} engines: {node: ^10 || ^12 || >=14} @@ -716,8 +750,8 @@ packages: shiki@2.5.0: resolution: {integrity: sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ==} - source-map-js@1.2.1: - resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} + source-map-js@1.2.2: + resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} engines: {node: '>=0.10.0'} space-separated-tokens@2.0.2: @@ -737,6 +771,10 @@ packages: tabbable@6.5.0: resolution: {integrity: sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==} + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} @@ -761,22 +799,27 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} - vite@5.4.21: - resolution: {integrity: sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==} - engines: {node: ^18.0.0 || >=20.0.0} + vite@6.4.3: + resolution: {integrity: sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 + '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 + jiti: '>=1.21.0' less: '*' lightningcss: ^1.21.0 sass: '*' sass-embedded: '*' stylus: '*' sugarss: '*' - terser: ^5.4.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 peerDependenciesMeta: '@types/node': optional: true + jiti: + optional: true less: optional: true lightningcss: @@ -791,6 +834,10 @@ packages: optional: true terser: optional: true + tsx: + optional: true + yaml: + optional: true vitepress@1.6.4: resolution: {integrity: sha512-+2ym1/+0VVrbhNyRoFFesVvBvHAVMZMK0rw60E3X/5349M1GuVdKeazuksqopEdvkKwKGs21Q729jX81/bkBJg==} @@ -967,73 +1014,82 @@ snapshots: transitivePeerDependencies: - '@algolia/client-search' - '@esbuild/aix-ppc64@0.21.5': + '@esbuild/aix-ppc64@0.25.12': + optional: true + + '@esbuild/android-arm64@0.25.12': + optional: true + + '@esbuild/android-arm@0.25.12': + optional: true + + '@esbuild/android-x64@0.25.12': optional: true - '@esbuild/android-arm64@0.21.5': + '@esbuild/darwin-arm64@0.25.12': optional: true - '@esbuild/android-arm@0.21.5': + '@esbuild/darwin-x64@0.25.12': optional: true - '@esbuild/android-x64@0.21.5': + '@esbuild/freebsd-arm64@0.25.12': optional: true - '@esbuild/darwin-arm64@0.21.5': + '@esbuild/freebsd-x64@0.25.12': optional: true - '@esbuild/darwin-x64@0.21.5': + '@esbuild/linux-arm64@0.25.12': optional: true - '@esbuild/freebsd-arm64@0.21.5': + '@esbuild/linux-arm@0.25.12': optional: true - '@esbuild/freebsd-x64@0.21.5': + '@esbuild/linux-ia32@0.25.12': optional: true - '@esbuild/linux-arm64@0.21.5': + '@esbuild/linux-loong64@0.25.12': optional: true - '@esbuild/linux-arm@0.21.5': + '@esbuild/linux-mips64el@0.25.12': optional: true - '@esbuild/linux-ia32@0.21.5': + '@esbuild/linux-ppc64@0.25.12': optional: true - '@esbuild/linux-loong64@0.21.5': + '@esbuild/linux-riscv64@0.25.12': optional: true - '@esbuild/linux-mips64el@0.21.5': + '@esbuild/linux-s390x@0.25.12': optional: true - '@esbuild/linux-ppc64@0.21.5': + '@esbuild/linux-x64@0.25.12': optional: true - '@esbuild/linux-riscv64@0.21.5': + '@esbuild/netbsd-arm64@0.25.12': optional: true - '@esbuild/linux-s390x@0.21.5': + '@esbuild/netbsd-x64@0.25.12': optional: true - '@esbuild/linux-x64@0.21.5': + '@esbuild/openbsd-arm64@0.25.12': optional: true - '@esbuild/netbsd-x64@0.21.5': + '@esbuild/openbsd-x64@0.25.12': optional: true - '@esbuild/openbsd-x64@0.21.5': + '@esbuild/openharmony-arm64@0.25.12': optional: true - '@esbuild/sunos-x64@0.21.5': + '@esbuild/sunos-x64@0.25.12': optional: true - '@esbuild/win32-arm64@0.21.5': + '@esbuild/win32-arm64@0.25.12': optional: true - '@esbuild/win32-ia32@0.21.5': + '@esbuild/win32-ia32@0.25.12': optional: true - '@esbuild/win32-x64@0.21.5': + '@esbuild/win32-x64@0.25.12': optional: true '@iconify-json/simple-icons@1.2.94': @@ -1187,9 +1243,9 @@ snapshots: '@ungap/structured-clone@1.4.0': {} - '@vitejs/plugin-vue@5.2.4(vite@5.4.21)(vue@3.5.42)': + '@vitejs/plugin-vue@5.2.4(vite@6.4.3)(vue@3.5.42)': dependencies: - vite: 5.4.21 + vite: 6.4.3 vue: 3.5.42 '@vue/compiler-core@3.5.42': @@ -1198,7 +1254,7 @@ snapshots: '@vue/shared': 3.5.42 entities: 7.0.1 estree-walker: 2.0.2 - source-map-js: 1.2.1 + source-map-js: 1.2.2 '@vue/compiler-dom@3.5.42': dependencies: @@ -1215,7 +1271,7 @@ snapshots: estree-walker: 2.0.2 magic-string: 0.30.21 postcss: 8.5.26 - source-map-js: 1.2.1 + source-map-js: 1.2.2 '@vue/compiler-ssr@3.5.42': dependencies: @@ -1332,34 +1388,41 @@ snapshots: entities@7.0.1: {} - esbuild@0.21.5: + esbuild@0.25.12: optionalDependencies: - '@esbuild/aix-ppc64': 0.21.5 - '@esbuild/android-arm': 0.21.5 - '@esbuild/android-arm64': 0.21.5 - '@esbuild/android-x64': 0.21.5 - '@esbuild/darwin-arm64': 0.21.5 - '@esbuild/darwin-x64': 0.21.5 - '@esbuild/freebsd-arm64': 0.21.5 - '@esbuild/freebsd-x64': 0.21.5 - '@esbuild/linux-arm': 0.21.5 - '@esbuild/linux-arm64': 0.21.5 - '@esbuild/linux-ia32': 0.21.5 - '@esbuild/linux-loong64': 0.21.5 - '@esbuild/linux-mips64el': 0.21.5 - '@esbuild/linux-ppc64': 0.21.5 - '@esbuild/linux-riscv64': 0.21.5 - '@esbuild/linux-s390x': 0.21.5 - '@esbuild/linux-x64': 0.21.5 - '@esbuild/netbsd-x64': 0.21.5 - '@esbuild/openbsd-x64': 0.21.5 - '@esbuild/sunos-x64': 0.21.5 - '@esbuild/win32-arm64': 0.21.5 - '@esbuild/win32-ia32': 0.21.5 - '@esbuild/win32-x64': 0.21.5 + '@esbuild/aix-ppc64': 0.25.12 + '@esbuild/android-arm': 0.25.12 + '@esbuild/android-arm64': 0.25.12 + '@esbuild/android-x64': 0.25.12 + '@esbuild/darwin-arm64': 0.25.12 + '@esbuild/darwin-x64': 0.25.12 + '@esbuild/freebsd-arm64': 0.25.12 + '@esbuild/freebsd-x64': 0.25.12 + '@esbuild/linux-arm': 0.25.12 + '@esbuild/linux-arm64': 0.25.12 + '@esbuild/linux-ia32': 0.25.12 + '@esbuild/linux-loong64': 0.25.12 + '@esbuild/linux-mips64el': 0.25.12 + '@esbuild/linux-ppc64': 0.25.12 + '@esbuild/linux-riscv64': 0.25.12 + '@esbuild/linux-s390x': 0.25.12 + '@esbuild/linux-x64': 0.25.12 + '@esbuild/netbsd-arm64': 0.25.12 + '@esbuild/netbsd-x64': 0.25.12 + '@esbuild/openbsd-arm64': 0.25.12 + '@esbuild/openbsd-x64': 0.25.12 + '@esbuild/openharmony-arm64': 0.25.12 + '@esbuild/sunos-x64': 0.25.12 + '@esbuild/win32-arm64': 0.25.12 + '@esbuild/win32-ia32': 0.25.12 + '@esbuild/win32-x64': 0.25.12 estree-walker@2.0.2: {} + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + focus-trap@7.8.0: dependencies: tabbable: 6.5.0 @@ -1440,11 +1503,13 @@ snapshots: picocolors@1.1.1: {} + picomatch@4.0.7: {} + postcss@8.5.26: dependencies: nanoid: 3.3.18 picocolors: 1.1.1 - source-map-js: 1.2.1 + source-map-js: 1.2.2 preact@10.29.8: {} @@ -1507,7 +1572,7 @@ snapshots: '@shikijs/vscode-textmate': 10.0.2 '@types/hast': 3.0.5 - source-map-js@1.2.1: {} + source-map-js@1.2.2: {} space-separated-tokens@2.0.2: {} @@ -1524,6 +1589,11 @@ snapshots: tabbable@6.5.0: {} + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + trim-lines@3.0.1: {} unist-util-is@6.0.1: @@ -1559,11 +1629,14 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vite@5.4.21: + vite@6.4.3: dependencies: - esbuild: 0.21.5 + esbuild: 0.25.12 + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 postcss: 8.5.26 rollup: 4.63.1 + tinyglobby: 0.2.17 optionalDependencies: fsevents: 2.3.3 @@ -1576,7 +1649,7 @@ snapshots: '@shikijs/transformers': 2.5.0 '@shikijs/types': 2.5.0 '@types/markdown-it': 14.2.0 - '@vitejs/plugin-vue': 5.2.4(vite@5.4.21)(vue@3.5.42) + '@vitejs/plugin-vue': 5.2.4(vite@6.4.3)(vue@3.5.42) '@vue/devtools-api': 7.7.10 '@vue/shared': 3.5.42 '@vueuse/core': 12.8.2 @@ -1585,7 +1658,7 @@ snapshots: mark.js: 8.11.1 minisearch: 7.2.0 shiki: 2.5.0 - vite: 5.4.21 + vite: 6.4.3 vue: 3.5.42 optionalDependencies: postcss: 8.5.26 @@ -1599,6 +1672,7 @@ snapshots: - drauu - fuse.js - idb-keyval + - jiti - jwt-decode - less - lightningcss @@ -1614,8 +1688,10 @@ snapshots: - stylus - sugarss - terser + - tsx - typescript - universal-cookie + - yaml vue@3.5.42: dependencies: From 3eaaa3abb8054aca57f51af9845bcb6af65f17f5 Mon Sep 17 00:00:00 2001 From: shawn Date: Tue, 13 Oct 2026 09:37:28 +0800 Subject: [PATCH 3/4] fix: use the latest supported vite 6 patch --- package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index fc7b6ea..f0f06db 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "pnpm": { "overrides": { - "vite": "6.4.3" + "vite": "6.4.4" }, "onlyBuiltDependencies": [ "esbuild" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b739ce..ca83bd2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,7 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: - vite: 6.4.3 + vite: 6.4.4 importers: @@ -498,7 +498,7 @@ packages: resolution: {integrity: sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==} engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: - vite: 6.4.3 + vite: 6.4.4 vue: ^3.2.25 '@vue/compiler-core@3.5.42': @@ -799,8 +799,8 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} - vite@6.4.3: - resolution: {integrity: sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==} + vite@6.4.4: + resolution: {integrity: sha512-xGjU/SyjeNyb0E4KxXBvYz/1C+3JXuujvf2hXNOtnlcE+58o5ajd9N2/n2VhkiJvpCP2qQasnUpx5PXNeI+p1Q==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: @@ -1243,9 +1243,9 @@ snapshots: '@ungap/structured-clone@1.4.0': {} - '@vitejs/plugin-vue@5.2.4(vite@6.4.3)(vue@3.5.42)': + '@vitejs/plugin-vue@5.2.4(vite@6.4.4)(vue@3.5.42)': dependencies: - vite: 6.4.3 + vite: 6.4.4 vue: 3.5.42 '@vue/compiler-core@3.5.42': @@ -1629,7 +1629,7 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vite@6.4.3: + vite@6.4.4: dependencies: esbuild: 0.25.12 fdir: 6.5.0(picomatch@4.0.7) @@ -1649,7 +1649,7 @@ snapshots: '@shikijs/transformers': 2.5.0 '@shikijs/types': 2.5.0 '@types/markdown-it': 14.2.0 - '@vitejs/plugin-vue': 5.2.4(vite@6.4.3)(vue@3.5.42) + '@vitejs/plugin-vue': 5.2.4(vite@6.4.4)(vue@3.5.42) '@vue/devtools-api': 7.7.10 '@vue/shared': 3.5.42 '@vueuse/core': 12.8.2 @@ -1658,7 +1658,7 @@ snapshots: mark.js: 8.11.1 minisearch: 7.2.0 shiki: 2.5.0 - vite: 6.4.3 + vite: 6.4.4 vue: 3.5.42 optionalDependencies: postcss: 8.5.26 From 3efac5bf5446c5189f8181c3312d25dae74695be Mon Sep 17 00:00:00 2001 From: shawn Date: Tue, 13 Oct 2026 10:04:09 +0800 Subject: [PATCH 4/4] test: stabilize share rotation and actor lifecycle checks --- Sources/LocalShare/FileServer.swift | 4 +- .../LocalShareTests/RemoteSharingTests.swift | 3 +- .../LocalShareTests/ShareRotationTests.swift | 98 +++++++++---------- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/Sources/LocalShare/FileServer.swift b/Sources/LocalShare/FileServer.swift index 6c6b49d..f44b30c 100644 --- a/Sources/LocalShare/FileServer.swift +++ b/Sources/LocalShare/FileServer.swift @@ -327,7 +327,7 @@ final class FileServer { // MARK: - 请求处理 - private func handle(_ req: HttpRequest) -> HttpResponse { + func handle(_ req: HttpRequest, afterAuthentication: () -> Void = {}) -> HttpResponse { // Tailscale 开关是网络边界,必须先于访问码和 token 鉴权;即使拿着有效链接,关闭后也立即拒绝。 guard Self.allowsClient(address: req.address, tailscaleAccessEnabled: tailscaleAccessEnabled) else { return htmlResponse(403, "Forbidden", Self.forbiddenPage( @@ -381,6 +381,8 @@ final class FileServer { // 鉴权通过的每个请求都刷新该 IP 的活跃时间(含心跳与下载中的请求)。 touchPresence(clientAddress, lookupName: !remoteMode) + // Allow tests to rotate the share at the authenticated request boundary. + afterAuthentication() // 已经有有效 Cookie 却打开 /ls/join 时直接回当前分享入口,不再重复要求输入短码。 if req.method == "GET", req.path == "/ls/join" { diff --git a/Tests/LocalShareTests/RemoteSharingTests.swift b/Tests/LocalShareTests/RemoteSharingTests.swift index e648d4a..ef6f48b 100644 --- a/Tests/LocalShareTests/RemoteSharingTests.swift +++ b/Tests/LocalShareTests/RemoteSharingTests.swift @@ -117,7 +117,8 @@ final class RemoteSharingTests: XCTestCase { XCTAssertEqual(String(data: frame.dropFirst(4).dropFirst(5), encoding: .utf8), "hello") } - @MainActor func testRemotePairStatusUsesUserDefaultsMarker() { + // Keep MainActor-owned objects inside XCTest's async task context during teardown. + @MainActor func testRemotePairStatusUsesUserDefaultsMarker() async { let key = "remotePairedServerAddresses" let previous = UserDefaults.standard.object(forKey: key) defer { diff --git a/Tests/LocalShareTests/ShareRotationTests.swift b/Tests/LocalShareTests/ShareRotationTests.swift index 35433fe..a1d7787 100644 --- a/Tests/LocalShareTests/ShareRotationTests.swift +++ b/Tests/LocalShareTests/ShareRotationTests.swift @@ -1,10 +1,9 @@ import XCTest -import Darwin import Swifter @testable import LocalShare final class ShareRotationTests: XCTestCase { - func testInFlightRequestsStayWithinAuthenticatedShare() async throws { + func testInFlightRequestsStayWithinAuthenticatedShare() throws { let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true) defer { try? FileManager.default.removeItem(at: root) } @@ -17,64 +16,63 @@ final class ShareRotationTests: XCTestCase { for upload in [false, true] { let server = FileServer(share: upload ? .directory(oldRoot) : .file(oldFile), token: "old-token") server.uploadEnabled = upload - let port = try server.start(preferredPorts: [in_port_t.random(in: 30000...50000)]) - defer { server.stop() } - let fd = Darwin.socket(AF_INET, SOCK_STREAM, 0) - XCTAssertGreaterThanOrEqual(fd, 0) - var noSignal: Int32 = 1 - _ = setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &noSignal, socklen_t(MemoryLayout.size)) - var timeout = timeval(tv_sec: 5, tv_usec: 0) - _ = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, socklen_t(MemoryLayout.size)) - var address = sockaddr_in() - address.sin_len = UInt8(MemoryLayout.size) - address.sin_family = sa_family_t(AF_INET) - address.sin_port = port.bigEndian - _ = "127.0.0.1".withCString { inet_pton(AF_INET, $0, &address.sin_addr) } - let connected = withUnsafePointer(to: &address) { - $0.withMemoryRebound(to: sockaddr.self, capacity: 1) { Darwin.connect(fd, $0, socklen_t(MemoryLayout.size)) } - } - XCTAssertEqual(connected, 0) - let socket = Swifter.Socket(socketFileDescriptor: fd) - defer { socket.close() } - // Presence is recorded after auth, before this long path is decoded and routed. - // Single-file reads ignore the filename; repeated encoded slashes upload at the folder root. - let path = "/" + String(repeating: upload ? "%2f" : "%61", count: 500_000) - let body = upload ? "--rotation\r\nContent-Disposition: form-data; name=\"file\"; filename=\"upload.txt\"\r\nContent-Type: text/plain\r\n\r\nupload\r\n--rotation--\r\n" : "" - let headers = upload ? "Content-Type: multipart/form-data; boundary=rotation\r\nContent-Length: \(body.utf8.count)\r\n" : "" - try socket.writeUTF8("\(upload ? "POST" : "GET") \(path)?t=old-token HTTP/1.1\r\nHost: localhost\r\n\(headers)\r\n\(body)") - // The intentionally large request line must finish parsing before the rotation. - let deadline = Date().addingTimeInterval(15) - while server.activeViewers() == 0 && Date() < deadline { - try await Task.sleep(nanoseconds: 100_000) + let request = HttpRequest() + request.method = upload ? "POST" : "GET" + request.path = upload ? "/" : "/old.txt" + request.queryParams = [("t", "old-token")] + request.address = "127.0.0.1" + if upload { + request.headers["content-type"] = "multipart/form-data; boundary=rotation" + request.body = Array("--rotation\r\nContent-Disposition: form-data; name=\"file\"; filename=\"upload.txt\"\r\nContent-Type: text/plain\r\n\r\nupload\r\n--rotation--\r\n".utf8) } - guard server.activeViewers() == 1 else { - XCTFail("request did not reach authenticated routing") - return + var rotated = false + // Rotate after authentication and before content routing, independent of socket timing. + let response = server.handle(request) { + XCTAssertEqual(server.activeViewers(), 1) + server.token = "new-token" + server.share = upload ? .directory(newRoot) : .file(newFile) + rotated = true } - server.token = "new-token" - server.share = upload ? .directory(newRoot) : .file(newFile) - let status = try socket.readLine() - XCTAssertTrue(status.contains("200")) - while !(try socket.readLine()).isEmpty {} + XCTAssertTrue(rotated) + XCTAssertEqual(response.statusCode, 200) + XCTAssertTrue(response.headers()["Set-Cookie"]?.contains("old-token") == true) if upload { XCTAssertEqual(try String(contentsOf: oldRoot.appendingPathComponent("upload.txt")), "upload") XCTAssertFalse(FileManager.default.fileExists(atPath: newRoot.appendingPathComponent("upload.txt").path)) } else { - XCTAssertEqual(String(decoding: try socket.read(length: 3), as: UTF8.self), "old") + XCTAssertEqual(try responseText(response), "old") } - let base = "http://127.0.0.1:\(port)" - let configuration = URLSessionConfiguration.ephemeral - configuration.httpCookieStorage = nil - let session = URLSession(configuration: configuration) - defer { session.invalidateAndCancel() } - let (_, rejected) = try await session.data(from: URL(string: base + "/?t=old-token")!) - XCTAssertEqual((rejected as? HTTPURLResponse)?.statusCode, 403) - let (newContent, accepted) = try await session.data(from: URL(string: base + "/new.txt?t=new-token")!) - XCTAssertEqual((accepted as? HTTPURLResponse)?.statusCode, 200) - XCTAssertEqual(String(decoding: newContent, as: UTF8.self), "new") + request.method = "GET" + request.path = "/new.txt" + request.body = [] + request.headers = [:] + XCTAssertEqual(server.handle(request).statusCode, 403) + request.queryParams = [("t", "new-token")] + let accepted = server.handle(request) + XCTAssertEqual(accepted.statusCode, 200) + XCTAssertEqual(try responseText(accepted), "new") } } + private func responseText(_ response: HttpResponse) throws -> String { + guard case .raw(_, _, _, let write) = response else { + XCTFail("expected a raw file response") + return "" + } + let writer = BodyWriter() + try write?(writer) + return String(decoding: writer.data, as: UTF8.self) + } + + private final class BodyWriter: HttpResponseBodyWriter { + var data = Data() + func write(_ file: String.File) throws { XCTFail("unexpected file writer") } + func write(_ bytes: [UInt8]) throws { data.append(contentsOf: bytes) } + func write(_ bytes: ArraySlice) throws { data.append(contentsOf: bytes) } + func write(_ bytes: NSData) throws { data.append(bytes as Data) } + func write(_ bytes: Data) throws { data.append(bytes) } + } + func testTextBreadcrumbReturnsToMountedShareRoot() { let crumbs = DirectoryListing.breadcrumb(requestPath: "/文本", rootName: "Folder", navigationPath: "/ls/text") XCTAssertTrue(crumbs.contains("href=\"../\""))