Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sc 13172/slug domain #137

Merged
merged 6 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/beacon-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"@lingui/macro": "^3.16.1",
"@sentry/react": "^7.33.0",
"@sentry/tracing": "^7.33.0",
"@rotational/beacon-core": "^1.1.1",
"@rotational/beacon-foundation": "^1.0.1",
"@rotational/beacon-core": "^2.0.0",
"@rotational/beacon-foundation": "^2.0.0",
"@radix-ui/react-avatar": "^1.0.1",
"@tanstack/react-query": "^4.22.4",
"@testing-library/react": "^13.4.0",
Expand Down
8 changes: 4 additions & 4 deletions web/beacon-app/public/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -137763,15 +137763,15 @@ video {
border-radius: 9999px;
}

.hover\:bg-icon-hover:hover {
background-color: rgba(217, 217, 217, 0.4);
}

.hover\:bg-secondary-800:hover {
--tw-bg-opacity: 1;
background-color: rgb(73 95 109 / var(--tw-bg-opacity));
}

.hover\:bg-icon-hover:hover {
background-color: rgba(217, 217, 217, 0.4);
}

[dir="ltr"] .ltr\:mr-3 {
margin-right: 0.75rem;
}
Expand Down
20 changes: 20 additions & 0 deletions web/beacon-app/src/utils/__tests__/slugifyDomain.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import slugify from "../slugifyDomain";
import { describe, expect, it } from "vitest";

describe("#slugify", () => {
it("returns ensign.rotational.io when org name is empty", () => {
expect(slugify("")).toBe("ensign.rotational.io/")
})

it("returns ensign.rotational.io/rotational-labs-inc when org name is Roational Labs, Inc.", () => {
expect(slugify("Rotational Labs, Inc.")).toBe("ensign.rotational.io/rotational-labs-inc")
})

it("returns ensign.rotational.io/hermes-international-sa when org name is Hermès International S.A.", () => {
expect(slugify("Hermès International S.A.")).toBe("ensign.rotational.io/hermes-international-sa")
})

it("returns ensign.rotational.io/baskin-robins when org name is Baskin Robins", () => {
expect(slugify("Baskin-Robins")).toBe("ensign.rotational.io/baskin-robins")
})
})
14 changes: 14 additions & 0 deletions web/beacon-app/src/utils/slugifyDomain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Creates a URL with an organization domain */
/* Ex. Rotational Labs -> ensign.rotational.io/rotational-labs */

export default function slugify(domain: string) {
return "ensign.rotational.io/" +
domain
.normalize('NFKD') /* Splits the base character and its accent */
.replace( /[\u0300-\u036f]/g, '' ) /* Deletes all the accents */
.toLowerCase()
.trim()
.replace(/\s+/g, '-')
.replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-');
}