fix: correct full url when using sub-path (#38712)

fix #38708

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
wxiaoguang
2026-07-31 03:09:32 +08:00
committed by GitHub
parent d87d26d735
commit a30d865b78
12 changed files with 19 additions and 44 deletions
+1 -11
View File
@@ -1,7 +1,7 @@
import {
dirname, basename, extname, formatBytes, isObject, stripTags, parseIssueHref,
translateMonth, translateDay, blobToDataURI,
toAbsoluteUrl, encodeURLEncodedBase64, decodeURLEncodedBase64, isImageFile, isVideoFile, parseRepoOwnerPathInfo,
encodeURLEncodedBase64, decodeURLEncodedBase64, isImageFile, isVideoFile, parseRepoOwnerPathInfo,
} from './utils.ts';
test('dirname', () => {
@@ -88,16 +88,6 @@ test('blobToDataURI', async () => {
expect(await blobToDataURI(blob)).toEqual('data:application/json;base64,eyJ0ZXN0Ijp0cnVlfQ==');
});
test('toAbsoluteUrl', () => {
expect(toAbsoluteUrl('//host/dir')).toEqual('http://host/dir');
expect(toAbsoluteUrl('https://host/dir')).toEqual('https://host/dir');
expect(toAbsoluteUrl('')).toEqual('http://localhost:3000');
expect(toAbsoluteUrl('/user/repo')).toEqual('http://localhost:3000/user/repo');
expect(() => toAbsoluteUrl('path')).toThrow('unsupported');
});
test('encodeURLEncodedBase64, decodeURLEncodedBase64', () => {
const encoder = new TextEncoder();
const uint8array = encoder.encode.bind(encoder);