Refactor and regroup urlHelpers utils (#6462)

* fix: refactor urlHelpers

* fix: move to /plugins/slack/shared

* fix: remove .babelrc

* fix: remove Outline class

* fix: Slack -> SlackUtils

* fix: UrlHelper class
This commit is contained in:
Apoorv Mishra
2024-02-29 11:41:03 +05:30
committed by GitHub
parent 021cd253af
commit fd34a6d19c
20 changed files with 146 additions and 127 deletions

10
shared/utils/UrlHelper.ts Normal file
View File

@@ -0,0 +1,10 @@
export class UrlHelper {
public static github = "https://www.github.com/outline/outline/issues";
public static twitter = "https://twitter.com/getoutline";
public static contact = "https://www.getoutline.com/contact";
public static developers = "https://www.getoutline.com/developers";
public static changelog = "https://www.getoutline.com/changelog";
public static SLUG_URL_REGEX = /^(?:[0-9a-zA-Z-_~]*-)?([a-zA-Z0-9]{10,15})$/;
public static SHARE_URL_SLUG_REGEX = /^[0-9a-z-]+$/;
}

View File

@@ -1,53 +0,0 @@
import env from "../env";
export function slackAuth(
state: string,
scopes: string[] = [
"identity.email",
"identity.basic",
"identity.avatar",
"identity.team",
],
clientId: string,
redirectUri = `${env.URL}/auth/slack.callback`
): string {
const baseUrl = "https://slack.com/oauth/authorize";
const params = {
client_id: clientId,
scope: scopes ? scopes.join(" ") : "",
redirect_uri: redirectUri,
state,
};
const urlParams = Object.keys(params)
.map((key) => `${key}=${encodeURIComponent(params[key])}`)
.join("&");
return `${baseUrl}?${urlParams}`;
}
export function githubUrl(): string {
return "https://www.github.com/outline";
}
export function githubIssuesUrl(): string {
return "https://www.github.com/outline/outline/issues";
}
export function twitterUrl(): string {
return "https://twitter.com/getoutline";
}
export function feedbackUrl(): string {
return "https://www.getoutline.com/contact";
}
export function developersUrl(): string {
return "https://www.getoutline.com/developers";
}
export function changelogUrl(): string {
return "https://www.getoutline.com/changelog";
}
export const SLUG_URL_REGEX = /^(?:[0-9a-zA-Z-_~]*-)?([a-zA-Z0-9]{10,15})$/;
export const SHARE_URL_SLUG_REGEX = /^[0-9a-z-]+$/;