mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 11:27:06 +02:00
@@ -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);
|
||||
});
|
||||
@@ -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