Skip to content

Commit

Permalink
Merge pull request #1934 from cardstack/CS-7671-remove-https-from-web…
Browse files Browse the repository at this point in the history
…site-field

Remove https when displaying website fields
  • Loading branch information
richardhjtan authored Dec 16, 2024
2 parents 5a33040 + eea5b03 commit 493c8d2
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 />
</:thumbnail>
</EntityDisplay>
</template>
};

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

0 comments on commit 493c8d2

Please sign in to comment.