mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-16 22:21:16 +00:00
@@ -4,6 +4,7 @@ import {registerGlobalInitFunc} from '../../modules/observer.ts';
|
||||
import {queryElems} from '../../utils/dom.ts';
|
||||
import {errorMessage} from '../../modules/errors.ts';
|
||||
import {submitFormFetchAction} from '../common-fetch-action.ts';
|
||||
import {cutString} from '../../utils/string.ts';
|
||||
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
@@ -158,7 +159,7 @@ export class ConfigFormValueMapper {
|
||||
const apps: Array<{DisplayName: string, OpenURL: string}> = [];
|
||||
const lines = cfgVal.split('\n');
|
||||
for (const line of lines) {
|
||||
let [displayName, openUrl] = line.split('=', 2);
|
||||
let [displayName, openUrl] = cutString(line, '=');
|
||||
displayName = displayName.trim();
|
||||
openUrl = openUrl?.trim() ?? '';
|
||||
if (!displayName || !openUrl) continue;
|
||||
|
||||
13
web_src/js/utils/string.test.ts
Normal file
13
web_src/js/utils/string.test.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {cutString} from './string.ts';
|
||||
|
||||
test('cutString', () => {
|
||||
let [before, after, ok] = cutString('a = b = c', '=');
|
||||
expect(before).toBe('a ');
|
||||
expect(after).toBe(' b = c');
|
||||
expect(ok).toBe(true);
|
||||
|
||||
[before, after, ok] = cutString(' a ', '=');
|
||||
expect(before).toBe(' a ');
|
||||
expect(after).toBe('');
|
||||
expect(ok).toBe(false);
|
||||
});
|
||||
5
web_src/js/utils/string.ts
Normal file
5
web_src/js/utils/string.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export function cutString(s: string, sep: string): [string, string, boolean] {
|
||||
const index = s.indexOf(sep);
|
||||
if (index === -1) return [s, '', false];
|
||||
return [s.substring(0, index), s.substring(index + sep.length), true];
|
||||
}
|
||||
Reference in New Issue
Block a user