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

@qeepsake/rails-guid

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qeepsake/rails-guid

Tiny (zero dependancy) utility to create and extract rails guid strings in JavaScript 🛤

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-40%
Maintainers
2
Weekly downloads
 
Created
Source

Rails Guid for JavaScript

All Contributors

Zero dependancy utility for creating and extracting rails GUIDs from a string.

NPM JavaScript Style Guide

Install

npm install --save @qeepsake/rails-guid

Usage

Extracting Rails GUID

You can use extractRailsId to extract a Rails GUID from a string:

import { extractRailsId } from '@qeepsake/rails-guid';

const guid = "gid://qeepsake-rails/Model/55587";
extractRailsId(guid) // -> 55587

Creating Rails GUID

You can use the createRailsId to create Rails GUID:

import { createRailsId } from '@qeepsake/rails-guid';

const id = 55587 || "55587";
createRailsId(id, "Model") // -> gid://qeepsake-rails/Model/55587

Tetsing for Extracted Rails ID

import { isExtractedRailsId } from '@qeepsake/rails-guid';

isExtractedRailsId("55587") // => true
isExtractedRailsId("gid://qeepsake-rails/Model/55587") // => false

Testing for Rails Global ID

You can use `isRailsId`` to test if a string is a valid Rails Global ID:

import { isRailsId } from '@qeepsake/rails-guid';

isRailsId("gid://qeepsake-rails/User/1")  // => true
isRailsId("gid://someotherapp/User/1")   // => true
isRailsId("User/1")                      // => false

This function tests if the string conforms to the general Rails gid structure: gid://<ANY_APP_NAME>/<MODEL_NAME>/<ID>.

License

MIT © lukebrandonfarrell

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Luke Brandon Farrell

📆 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 27 Sep 2023

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