Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@debtcollective/dc-header-component

Package Overview
Dependencies
Maintainers
6
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@debtcollective/dc-header-component - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

dist/collection/utils/normalise.js

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.5.0](https://github.com/debtcollective/packages/compare/@debtcollective/dc-header-component@3.4.0...@debtcollective/dc-header-component@3.5.0) (2021-06-18)
### Features
* **header:** avoid need to match certain format for urls ([#163](https://github.com/debtcollective/packages/issues/163)) ([8ab6467](https://github.com/debtcollective/packages/commit/8ab6467))
# [3.4.0](https://github.com/debtcollective/packages/compare/@debtcollective/dc-header-component@3.3.4...@debtcollective/dc-header-component@3.4.0) (2021-06-18)

@@ -8,0 +19,0 @@

27

dist/cjs/dc-header_4.cjs.entry.js

@@ -356,11 +356,17 @@ 'use strict';

const sanitiseSSOUrl = (ssoUrl) => {
if (ssoUrl === "/") {
const trimSlash = (url) => {
if (url === "/") {
return window.location.origin;
}
if (ssoUrl.charAt(ssoUrl.length - 1) === "/") {
return ssoUrl.slice(0, -1);
if (url.charAt(url.length - 1) === "/") {
return url.slice(0, -1);
}
return ssoUrl;
return url;
};
const addSlash = (url) => {
if (url.charAt(url.length - 1) !== "/") {
return `${url}/`;
}
return url;
};

@@ -372,3 +378,3 @@ /**

*/
const preffixCommunityURL = (community, str) => `${sanitiseSSOUrl(community)}/${str}`;
const preffixCommunityURL = (community, str) => `${trimSlash(community)}/${str}`;
/**

@@ -421,3 +427,3 @@ * Takes an object with avatar_template (typically user) and return a full

let currentUser;
let discourseEndpoint = sanitiseSSOUrl(community);
let discourseEndpoint = trimSlash(community);
try {

@@ -433,3 +439,3 @@ const csrfToken = await getCSRFToken(discourseEndpoint);

const logout = async (community, username) => {
let discourseEndpoint = sanitiseSSOUrl(community);
let discourseEndpoint = trimSlash(community);
const url = `${discourseEndpoint}/session/${username}`;

@@ -531,4 +537,9 @@ const csrfToken = await getCSRFToken(discourseEndpoint);

componentWillLoad() {
// Make sure to get the logo from prop or use default
this._logo = this.logo || this._defaultLogo;
this._logoSmall = this.logosmall || this._defaultLogoSmall;
// normalise the links to make sure they match the expected format
this.homepage = addSlash(this.homepage);
this.community = addSlash(this.community);
// Allow to fetch users session
this.syncCurrentUser();

@@ -535,0 +546,0 @@ }

@@ -7,2 +7,3 @@ import "./menu";

import { getGuestActions } from "../../utils/config";
import { addSlash } from "../../utils/normalise";
export class Header {

@@ -32,4 +33,9 @@ constructor() {

componentWillLoad() {
// Make sure to get the logo from prop or use default
this._logo = this.logo || this._defaultLogo;
this._logoSmall = this.logosmall || this._defaultLogoSmall;
// normalise the links to make sure they match the expected format
this.homepage = addSlash(this.homepage);
this.community = addSlash(this.community);
// Allow to fetch users session
this.syncCurrentUser();

@@ -36,0 +42,0 @@ }

@@ -1,2 +0,2 @@

import { sanitiseSSOUrl } from "../utils/sanitise";
import { trimSlash } from "../utils/normalise";
// https://stackoverflow.com/a/33829607/1422380

@@ -36,3 +36,3 @@ const getCSRFToken = async (discourseEndpoint) => {

let currentUser;
let discourseEndpoint = sanitiseSSOUrl(community);
let discourseEndpoint = trimSlash(community);
try {

@@ -48,3 +48,3 @@ const csrfToken = await getCSRFToken(discourseEndpoint);

export const logout = async (community, username) => {
let discourseEndpoint = sanitiseSSOUrl(community);
let discourseEndpoint = trimSlash(community);
const url = `${discourseEndpoint}/session/${username}`;

@@ -51,0 +51,0 @@ const csrfToken = await getCSRFToken(discourseEndpoint);

@@ -1,2 +0,2 @@

import { sanitiseSSOUrl } from "./sanitise";
import { trimSlash } from "./normalise";
/**

@@ -7,3 +7,3 @@ * preffix a given string with the base community URL.

*/
export const preffixCommunityURL = (community, str) => `${sanitiseSSOUrl(community)}/${str}`;
export const preffixCommunityURL = (community, str) => `${trimSlash(community)}/${str}`;
/**

@@ -10,0 +10,0 @@ * Takes an object with avatar_template (typically user) and return a full

@@ -352,11 +352,17 @@ import { r as registerInstance, c as createEvent, h, H as Host, g as getAssetPath } from './index-8956c047.js';

const sanitiseSSOUrl = (ssoUrl) => {
if (ssoUrl === "/") {
const trimSlash = (url) => {
if (url === "/") {
return window.location.origin;
}
if (ssoUrl.charAt(ssoUrl.length - 1) === "/") {
return ssoUrl.slice(0, -1);
if (url.charAt(url.length - 1) === "/") {
return url.slice(0, -1);
}
return ssoUrl;
return url;
};
const addSlash = (url) => {
if (url.charAt(url.length - 1) !== "/") {
return `${url}/`;
}
return url;
};

@@ -368,3 +374,3 @@ /**

*/
const preffixCommunityURL = (community, str) => `${sanitiseSSOUrl(community)}/${str}`;
const preffixCommunityURL = (community, str) => `${trimSlash(community)}/${str}`;
/**

@@ -417,3 +423,3 @@ * Takes an object with avatar_template (typically user) and return a full

let currentUser;
let discourseEndpoint = sanitiseSSOUrl(community);
let discourseEndpoint = trimSlash(community);
try {

@@ -429,3 +435,3 @@ const csrfToken = await getCSRFToken(discourseEndpoint);

const logout = async (community, username) => {
let discourseEndpoint = sanitiseSSOUrl(community);
let discourseEndpoint = trimSlash(community);
const url = `${discourseEndpoint}/session/${username}`;

@@ -527,4 +533,9 @@ const csrfToken = await getCSRFToken(discourseEndpoint);

componentWillLoad() {
// Make sure to get the logo from prop or use default
this._logo = this.logo || this._defaultLogo;
this._logoSmall = this.logosmall || this._defaultLogoSmall;
// normalise the links to make sure they match the expected format
this.homepage = addSlash(this.homepage);
this.community = addSlash(this.community);
// Allow to fetch users session
this.syncCurrentUser();

@@ -531,0 +542,0 @@ }

@@ -1,1 +0,1 @@

import{p as e,b as l}from"./p-1822b0d8.js";(()=>{const l=import.meta.url,o={};return""!==l&&(o.resourcesUrl=new URL(".",l).href),e(o)})().then((e=>l([["p-d2115092",[[1,"dc-header",{homepage:[1],community:[1],returnurl:[1],logo:[8],logosmall:[8],user:[32],isShrink:[32],scrollTop:[32],isMenuOpen:[32],isProfileMenuOpen:[32]},[[9,"scroll","handleScroll"],[0,"toggleMenu","toggleMenuHandler"],[0,"toggleProfileMenu","toggleProfileMenuHandler"],[0,"closeAll","closeAll"]]],[1,"dc-menu",{open:[4],community:[1],homepage:[1],host:[1],user:[16]},[[4,"keydown","handleEscapeKey"]]],[1,"dc-profile",{shrank:[4],expanded:[4],community:[1],homepage:[1],host:[1],user:[16]},[[4,"keydown","handleEscapeKey"]]],[4,"dc-link",{to:[1],target:[1],namespace:[1]},[[2,"click","handleClick"]]]]]],e)));
import{p as e,b as l}from"./p-1822b0d8.js";(()=>{const l=import.meta.url,o={};return""!==l&&(o.resourcesUrl=new URL(".",l).href),e(o)})().then((e=>l([["p-0d8ead4d",[[1,"dc-header",{homepage:[1],community:[1],returnurl:[1],logo:[8],logosmall:[8],user:[32],isShrink:[32],scrollTop:[32],isMenuOpen:[32],isProfileMenuOpen:[32]},[[9,"scroll","handleScroll"],[0,"toggleMenu","toggleMenuHandler"],[0,"toggleProfileMenu","toggleProfileMenuHandler"],[0,"closeAll","closeAll"]]],[1,"dc-menu",{open:[4],community:[1],homepage:[1],host:[1],user:[16]},[[4,"keydown","handleEscapeKey"]]],[1,"dc-profile",{shrank:[4],expanded:[4],community:[1],homepage:[1],host:[1],user:[16]},[[4,"keydown","handleEscapeKey"]]],[4,"dc-link",{to:[1],target:[1],namespace:[1]},[[2,"click","handleClick"]]]]]],e)));
{
"name": "@debtcollective/dc-header-component",
"version": "3.4.0",
"version": "3.5.0",
"description": "Stencil header component for debtcollective web apps",

@@ -42,3 +42,3 @@ "main": "dist/index.cjs.js",

"license": "BSD-3-Clause",
"gitHead": "807929eeef12dd63ca0a94ea6f49d871fc02456d"
"gitHead": "a9ac0fd751a8794ddb230313d2e8fcb2fec8837c"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc