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 - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

lib/is-extracted-rails-id.d.ts

4

lib/extract-rails-id.js

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

import { isExtractedRailsId } from './is-extracted-rails-id';
export function extractRailsId(gid, stripTimestamp = false) {
// Checks if ID has already been extracted, if so, return it
if (gid && isExtractedRailsId(gid))
return gid;
if (typeof gid === 'string' && (gid === null || gid === void 0 ? void 0 : gid.indexOf('/')) != -1) {

@@ -3,0 +7,0 @@ const gidComponents = gid.split('/');

export { extractRailsId } from './extract-rails-id';
export { createRailsId } from './create-rails-id';
export { isExtractedRailsId } from './is-extracted-rails-id';

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

function isExtractedRailsId(id) {
if (typeof id === 'string') {
return !id.startsWith('gid://') && id.indexOf(' ') == -1;
}
return false;
}
function extractRailsId(gid, stripTimestamp) {

@@ -6,2 +14,4 @@ if (stripTimestamp === void 0) {

if (gid && isExtractedRailsId(gid)) return gid;
if (typeof gid === 'string' && (gid === null || gid === void 0 ? void 0 : gid.indexOf('/')) != -1) {

@@ -31,2 +41,3 @@ var _extractedId;

exports.extractRailsId = extractRailsId;
exports.isExtractedRailsId = isExtractedRailsId;
//# sourceMappingURL=index.js.map

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

function isExtractedRailsId(id) {
if (typeof id === 'string') {
return !id.startsWith('gid://') && id.indexOf(' ') == -1;
}
return false;
}
function extractRailsId(gid, stripTimestamp) {

@@ -6,2 +14,4 @@ if (stripTimestamp === void 0) {

if (gid && isExtractedRailsId(gid)) return gid;
if (typeof gid === 'string' && (gid === null || gid === void 0 ? void 0 : gid.indexOf('/')) != -1) {

@@ -29,3 +39,3 @@ var _extractedId;

export { createRailsId, extractRailsId };
export { createRailsId, extractRailsId, isExtractedRailsId };
//# sourceMappingURL=index.modern.js.map

2

package.json
{
"name": "@qeepsake/rails-guid",
"version": "1.1.0",
"version": "1.2.0",
"description": "Tiny (zero dependancy) utility to create and extract rails guid strings in JavaScript 🛤",

@@ -5,0 +5,0 @@ "author": "lukebrandonfarrell",

@@ -40,2 +40,11 @@ # Rails Guid for JavaScript

### Tetsing for Extracted Rails ID
```js
import { isExtractedRailsId } from '@qeepsake/rails-guid';
isExtractedRailsId("55587") // => true
isExtractedRailsId("gid://qeepsake-rails/Model/55587") // => false
```
## License

@@ -42,0 +51,0 @@

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

import { isExtractedRailsId } from './is-extracted-rails-id'
/**

@@ -21,2 +23,5 @@ * Extract rails ID

): string | null {
// Checks if ID has already been extracted, if so, return it
if (gid && isExtractedRailsId(gid)) return gid
if (typeof gid === 'string' && gid?.indexOf('/') != -1) {

@@ -23,0 +28,0 @@ const gidComponents = gid.split('/')

export { extractRailsId } from './extract-rails-id'
export { createRailsId } from './create-rails-id'
export { isExtractedRailsId } from './is-extracted-rails-id'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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