mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-06 17:08:32 +00:00
* Fixed empty string to URLs conversion Closes #919. Signed-off-by: Akos Kitta <kittaakos@gmail.com> * #881: Fixed height of the 3rd part URLs `textarea` Closes #881. Signed-off-by: Akos Kitta <kittaakos@gmail.com>
This commit is contained in:
@@ -116,7 +116,7 @@ export interface Config {
|
||||
readonly sketchDirUri: string;
|
||||
readonly dataDirUri: string;
|
||||
readonly downloadsDirUri: string;
|
||||
readonly additionalUrls: string[];
|
||||
readonly additionalUrls: AdditionalUrls;
|
||||
readonly network: Network;
|
||||
readonly daemon: Daemon;
|
||||
}
|
||||
@@ -141,3 +141,32 @@ export namespace Config {
|
||||
);
|
||||
}
|
||||
}
|
||||
export type AdditionalUrls = string[];
|
||||
export namespace AdditionalUrls {
|
||||
export function parse(value: string, delimiter: ',' | 'newline'): string[] {
|
||||
return value
|
||||
.trim()
|
||||
.split(delimiter === ',' ? delimiter : /\r?\n/)
|
||||
.map((url) => url.trim())
|
||||
.filter((url) => !!url);
|
||||
}
|
||||
export function stringify(additionalUrls: AdditionalUrls): string {
|
||||
return additionalUrls.join(',');
|
||||
}
|
||||
export function sameAs(left: AdditionalUrls, right: AdditionalUrls): boolean {
|
||||
if (left.length !== right.length) {
|
||||
return false;
|
||||
}
|
||||
const localeCompare = (left: string, right: string) =>
|
||||
left.localeCompare(right);
|
||||
const normalize = (url: string) => url.toLowerCase();
|
||||
const normalizedLeft = left.map(normalize).sort(localeCompare);
|
||||
const normalizedRight = right.map(normalize).sort(localeCompare);
|
||||
for (let i = 0; i < normalizedLeft.length; i++) {
|
||||
if (normalizedLeft[i] !== normalizedRight[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user