enforce maxlength in frontend (#29389)
Set maxlength attribute in frontend to long file-name   (same for branch-name and commit-summary) (cherry picked from commit 756b952c52f1efbb137df36d5b97b370c8a45565)
This commit is contained in:
parent
70f3c32b91
commit
4662f4feac
5 changed files with 9 additions and 8 deletions
|
@ -2,13 +2,14 @@ import {encode, decode} from 'uint8-to-base64';
|
|||
|
||||
// transform /path/to/file.ext to file.ext
|
||||
export function basename(path = '') {
|
||||
return path ? path.replace(/^.*\//, '') : '';
|
||||
const lastSlashIndex = path.lastIndexOf('/');
|
||||
return lastSlashIndex < 0 ? path : path.substring(lastSlashIndex + 1);
|
||||
}
|
||||
|
||||
// transform /path/to/file.ext to .ext
|
||||
export function extname(path = '') {
|
||||
const [_, ext] = /.+(\.[^.]+)$/.exec(path) || [];
|
||||
return ext || '';
|
||||
const lastPointIndex = path.lastIndexOf('.');
|
||||
return lastPointIndex < 0 ? '' : path.substring(lastPointIndex);
|
||||
}
|
||||
|
||||
// test whether a variable is an object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue