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

@churchcenter/url

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@churchcenter/url

A dumb url origin generator in JS

  • 1.1.4-alpha.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

@churchcenter/url

Church Center origin generator for JavaScript.

Builds runtime-environment-considered origins and urls in JavaScript for Church Center subdomains. For those familiar with @planningcenter/url, it may be worth noting that this generator has no concerns about what application is building the urls.

Examples

This package is primarily concerned with building origins and urls in the browser. It is smart about inferring the Church Center origin from the current window.location.origin. If window.location.origin is unavailable (like in the tests), an origin can be passed explicitly, but you'll most likely only need that for composing urls across subdomains.

// window.location == "https://carlsbad.churchcenter.com/giving"
import { buildSubdomain, buildUrl } from "@churchcenter/url"

let api = buildSubdomain("api")
// => https://api.churchcenter.com

let myGroupsUrl = buildUrl("/groups/profile")
// => https://carlsbad.churchcenter.com/groups/profile

Composition

Want to build API urls or app-specific urls? Compose to your heart's content!

// window.location == "http://first.churchcenter.test/giving/profile"
import { buildSubdomain, buildUrl } from "@churchcenter/url"

function bouldGroupsUrl(pathname) {
  return buildUrl(`/groups${pathname}`)
}

let myGroupsUrl = buildGroupsUrl("/profile")
// => http://first.churchcenter.test/groups/profile

function buildApiUrl(pathname) {
  return buildUrl(pathname, buildSubdomain("api"))
}

function buildPeopleApiUrl(pathname) {
  return buildApiUrl(`/people/v2${pathname}`)
}

function buildFormUrl(id) {
  return buildPeopleApiUrl(`/forms/${id}`)
}

let formUrl = buildFormUrl(42)
// => http://api.churchcenter.test/people/v2/forms/42

// function build.... you get the idea

Installation

Script tag on Rails

<script type="javascript" src="https://unpkg.com/@churchcenter/url/dist/url.umd.js"></script>
<!-- exposed as global `ChurchCenterUrl` -->

Webpacker on Rails

yarn add @churchcenter/url
import { buildSubdomain, buildUrl } from "@churchcenter/url";

FAQs

Package last updated on 08 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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