ui(admin): add "working" React admin ui
This commit is contained in:
parent
d1c7494933
commit
5402584508
199 changed files with 13387 additions and 151 deletions
27
resources/scripts/helpers/splitStringWhitespace.ts
Normal file
27
resources/scripts/helpers/splitStringWhitespace.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Takes a string and splits it into an array by whitespace, ignoring any
|
||||
* text that is wrapped in quotes. You must escape quotes within a quoted
|
||||
* string, otherwise it will just split on those.
|
||||
*
|
||||
* Derived from https://stackoverflow.com/a/46946420
|
||||
*/
|
||||
export default (str: string): string[] => {
|
||||
let quoted = false;
|
||||
const parts = [ '' ] as string[];
|
||||
|
||||
for (const char of (str.trim().match(/\\?.|^$/g) || [])) {
|
||||
if (char === '"') {
|
||||
quoted = !quoted;
|
||||
} else if (!quoted && char === ' ') {
|
||||
parts.push('');
|
||||
} else {
|
||||
parts[Math.max(parts.length - 1, 0)] += char.replace(/\\(.)/, '$1');
|
||||
}
|
||||
}
|
||||
|
||||
if (parts.length === 1 && parts[0] === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return parts;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue