loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove joinPaths function (#26833)

Extract from https://github.com/go-gitea/gitea/pull/25940.

`assetUrlPrefix` is guaranteed to not contain trailing slashes, making
this function unneeded.

authored by

silverwind and committed by
GitHub
c35b16a9 19a1e1b2

+2 -53
+1 -3
web_src/js/bootstrap.js
··· 1 - import {joinPaths} from './utils.js'; 2 - 3 1 // DO NOT IMPORT window.config HERE! 4 2 // to make sure the error handler always works, we should never import `window.config`, because some user's custom template breaks it. 5 3 6 4 // This sets up the URL prefix used in webpack's chunk loading. 7 5 // This file must be imported before any lazy-loading is being attempted. 8 - __webpack_public_path__ = joinPaths(window?.config?.assetUrlPrefix ?? '/', '/'); 6 + __webpack_public_path__ = `${window.config?.assetUrlPrefix ?? '/assets'}/`; 9 7 10 8 export function showGlobalErrorMessage(msg) { 11 9 const pageContent = document.querySelector('.page-content');
-10
web_src/js/utils.js
··· 11 11 return ext || ''; 12 12 } 13 13 14 - // join a list of path segments with slashes, ensuring no double slashes 15 - export function joinPaths(...parts) { 16 - let str = ''; 17 - for (const part of parts) { 18 - if (!part) continue; 19 - str = !str ? part : `${str.replace(/\/$/, '')}/${part.replace(/^\//, '')}`; 20 - } 21 - return str; 22 - } 23 - 24 14 // test whether a variable is an object 25 15 export function isObject(obj) { 26 16 return Object.prototype.toString.call(obj) === '[object Object]';
+1 -40
web_src/js/utils.test.js
··· 1 1 import {expect, test} from 'vitest'; 2 2 import { 3 - basename, extname, isObject, stripTags, joinPaths, parseIssueHref, 3 + basename, extname, isObject, stripTags, parseIssueHref, 4 4 parseUrl, translateMonth, translateDay, blobToDataURI, 5 5 toAbsoluteUrl, encodeURLEncodedBase64, decodeURLEncodedBase64, 6 6 } from './utils.js'; ··· 16 16 expect(extname('/path/')).toEqual(''); 17 17 expect(extname('/path')).toEqual(''); 18 18 expect(extname('file.js')).toEqual('.js'); 19 - }); 20 - 21 - test('joinPaths', () => { 22 - expect(joinPaths('', '')).toEqual(''); 23 - expect(joinPaths('', 'b')).toEqual('b'); 24 - expect(joinPaths('', '/b')).toEqual('/b'); 25 - expect(joinPaths('', '/b/')).toEqual('/b/'); 26 - expect(joinPaths('a', '')).toEqual('a'); 27 - expect(joinPaths('/a', '')).toEqual('/a'); 28 - expect(joinPaths('/a/', '')).toEqual('/a/'); 29 - expect(joinPaths('a', 'b')).toEqual('a/b'); 30 - expect(joinPaths('a', '/b')).toEqual('a/b'); 31 - expect(joinPaths('/a', '/b')).toEqual('/a/b'); 32 - expect(joinPaths('/a', '/b')).toEqual('/a/b'); 33 - expect(joinPaths('/a/', '/b')).toEqual('/a/b'); 34 - expect(joinPaths('/a', '/b/')).toEqual('/a/b/'); 35 - expect(joinPaths('/a/', '/b/')).toEqual('/a/b/'); 36 - 37 - expect(joinPaths('', '', '')).toEqual(''); 38 - expect(joinPaths('', 'b', '')).toEqual('b'); 39 - expect(joinPaths('', 'b', 'c')).toEqual('b/c'); 40 - expect(joinPaths('', '', 'c')).toEqual('c'); 41 - expect(joinPaths('', '/b', '/c')).toEqual('/b/c'); 42 - expect(joinPaths('/a', '', '/c')).toEqual('/a/c'); 43 - expect(joinPaths('/a', '/b', '')).toEqual('/a/b'); 44 - 45 - expect(joinPaths('', '/')).toEqual('/'); 46 - expect(joinPaths('a', '/')).toEqual('a/'); 47 - expect(joinPaths('', '/', '/')).toEqual('/'); 48 - expect(joinPaths('/', '/')).toEqual('/'); 49 - expect(joinPaths('/', '')).toEqual('/'); 50 - expect(joinPaths('/', 'b')).toEqual('/b'); 51 - expect(joinPaths('/', 'b/')).toEqual('/b/'); 52 - expect(joinPaths('/', '', '/')).toEqual('/'); 53 - expect(joinPaths('/', 'b', '/')).toEqual('/b/'); 54 - expect(joinPaths('/', 'b/', '/')).toEqual('/b/'); 55 - expect(joinPaths('a', '/', '/')).toEqual('a/'); 56 - expect(joinPaths('/', '/', 'c')).toEqual('/c'); 57 - expect(joinPaths('/', '/', 'c/')).toEqual('/c/'); 58 19 }); 59 20 60 21 test('isObject', () => {