(core) Treat URLs in Markdown cells as absolute

Summary: The previous behavior didn't match HyperLink cells.

Test Plan: Browser test.

Reviewers: jarek

Reviewed By: jarek

Subscribers: jarek

Differential Revision: https://phab.getgrist.com/D4358
This commit is contained in:
George Gevoian
2024-09-30 12:34:35 -04:00
parent d2714da224
commit 1927c87413
2 changed files with 5 additions and 4 deletions

View File

@@ -224,7 +224,7 @@ export class UrlStateImpl {
/**
* Given value like `foo bar baz`, constructs URL by checking if `baz` is a valid URL and,
* if not, prepending `http://`.
* if not, prepending `https://`.
*/
export function constructUrl(value: CellValue): string {
if (typeof value !== 'string') {
@@ -235,8 +235,8 @@ export function constructUrl(value: CellValue): string {
// Try to construct a valid URL
return (new URL(url)).toString();
} catch (e) {
// Not a valid URL, so try to prefix it with http
return 'http://' + url;
// Not a valid URL, so try to prefix it with https
return 'https://' + url;
}
}