mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 16:51:33 +10:00
Firebase Stub: leading slash in reference path is ignored
This commit is contained in:
@ -135,18 +135,19 @@ class Database {
|
||||
}
|
||||
|
||||
ref(referencePath) {
|
||||
const existingRef = this._getReference(referencePath);
|
||||
if (existingRef) {
|
||||
existingRef.initializeQueryParameters();
|
||||
return existingRef;
|
||||
}
|
||||
|
||||
const newRef = new Reference(
|
||||
referencePath,
|
||||
(dataPath) => this._getData(dataPath),
|
||||
(dataPath, value) => this._setData(dataPath, value),
|
||||
(refPath) => this._getReference(refPath),
|
||||
);
|
||||
|
||||
const existingRef = this._getReference(newRef.path);
|
||||
if (existingRef) {
|
||||
existingRef.initializeQueryParameters();
|
||||
return existingRef;
|
||||
}
|
||||
|
||||
this._references[newRef.path] = newRef;
|
||||
return newRef;
|
||||
}
|
||||
|
||||
@ -5,15 +5,25 @@ import { debounce } from 'lodash';
|
||||
import DatabaseConstants from '../constants/database';
|
||||
import DataSnapshot from './dataSnapshot';
|
||||
|
||||
const parsePath = (path) => {
|
||||
if (!path) {
|
||||
throw new Error('path must be provided.');
|
||||
} else if (typeof path !== 'string') {
|
||||
throw new Error('path should be a string.');
|
||||
} else {
|
||||
let parsedPath = path.trim();
|
||||
|
||||
if (parsedPath[0] === '/') {
|
||||
parsedPath = parsedPath.substring(1);
|
||||
}
|
||||
|
||||
return parsedPath;
|
||||
}
|
||||
};
|
||||
|
||||
class Reference {
|
||||
constructor(path, getDatabaseData, setDatabaseData, getReference) {
|
||||
if (!path) {
|
||||
throw new Error('path must be provided.');
|
||||
} else if (typeof path !== 'string') {
|
||||
throw new Error('path should be a string.');
|
||||
} else {
|
||||
this._path = path;
|
||||
}
|
||||
this._path = parsePath(path);
|
||||
|
||||
this._uuid = uuidv4();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user