-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): return ID from extractRailsId if it is already extracted
- Loading branch information
Luke Farrell
committed
Sep 26, 2022
1 parent
f7bc62e
commit 43f9634
Showing
13 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { extractRailsId } from './extract-rails-id'; | ||
export { createRailsId } from './create-rails-id'; | ||
export { isExtractedRailsId } from './is-extracted-rails-id'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { extractRailsId } from './extract-rails-id'; | ||
export { createRailsId } from './create-rails-id'; | ||
export { isExtractedRailsId } from './is-extracted-rails-id'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Checks to see if the given string is a valid extracted Rails ID | ||
* i.e. 55587 and not gid://qeepsake-rails/JournalEntry/55587 | ||
* | ||
* @param id - rails ID | ||
* @returns if ID is extracted rails ID | ||
*/ | ||
export declare function isExtractedRailsId(id: string): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Checks to see if the given string is a valid extracted Rails ID | ||
* i.e. 55587 and not gid://qeepsake-rails/JournalEntry/55587 | ||
* | ||
* @param id - rails ID | ||
* @returns if ID is extracted rails ID | ||
*/ | ||
export function isExtractedRailsId(id) { | ||
if (typeof id === 'string') { | ||
// Extracted IDs should NOT start with gid:// with no empty spaces | ||
return !id.startsWith('gid://') && id.indexOf(' ') == -1; | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { extractRailsId } from './extract-rails-id' | ||
export { createRailsId } from './create-rails-id' | ||
export { isExtractedRailsId } from './is-extracted-rails-id' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Checks to see if the given string is a valid extracted Rails ID | ||
* i.e. 55587 and not gid://qeepsake-rails/JournalEntry/55587 | ||
* | ||
* @param id - rails ID | ||
* @returns if ID is extracted rails ID | ||
*/ | ||
export function isExtractedRailsId(id: string): boolean { | ||
if (typeof id === 'string') { | ||
// Extracted IDs should NOT start with gid:// with no empty spaces | ||
return !id.startsWith('gid://') && id.indexOf(' ') == -1 | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { isExtractedRailsId } = require('../src/is-extracted-rails-id'); | ||
|
||
test('Test non-extracted Rails ID equals false', () => { | ||
expect(isExtractedRailsId('gid://qeepsake-rails/MyModel/12345')).toBe(false); | ||
}); | ||
|
||
test('Test extracted Rails ID equals true', () => { | ||
expect(isExtractedRailsId('12345')).toBe(true); | ||
}); |