Skip to content

Commit

Permalink
Remove https when displaying website fields
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhjtan committed Dec 13, 2024
1 parent 49561c6 commit eea5b03
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/experiments-realm/website.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@ import { UrlField } from './url';
import { Component } from 'https://cardstack.com/base/card-api';
import { EntityDisplay } from './components/entity-display';

const domainWithPath = (urlString: string | null) => {
if (!urlString) {
return '';
}

const url = new URL(urlString);
return `${url.hostname}${url.pathname === '/' ? '' : url.pathname}`;
};

export class WebsiteField extends UrlField {
static icon = WorldWwwIcon;
static displayName = 'Website';

static atom = class Atom extends Component<typeof this> {
static atom = class Atom extends Component<typeof WebsiteField> {
<template>
<EntityDisplay @name={{@model}}>
<EntityDisplay @name={{domainWithPath @model}}>
<:thumbnail>
<WorldWwwIcon class='icon' />
</:thumbnail>
</EntityDisplay>
</template>
};

static embedded = class Embedded extends Component<typeof WebsiteField> {
<template>
{{domainWithPath @model}}
</template>
};
}

0 comments on commit eea5b03

Please sign in to comment.