Fire collections use idGeneration:'MONGO', so _id is a Mongo.ObjectID whose
toString() is ObjectID("<hex>"), not the bare hex. Interpolating _id into a
URL produced /fire/archive/ObjectID("c0..."), which no route matches -> the
fire-detail page 404'd. New hexId() helper returns the 24-char hex for an
ObjectID (and passes plain strings through); applied at the three string-context
sites: the map-marker click URL (MarkListeners), the active->archive redirect,
and the comments referenceId (Fires.js). Left falsePositives.insert untouched —
its check() expects a Meteor.Collection.ObjectID, so it takes the object.
Verified in browser: /fire/archive/<hex> and /fire/active/<hex> render the
detail page (map + comments), URL stays clean hex, no ObjectID( anywhere.
15 lines
747 B
JavaScript
15 lines
747 B
JavaScript
/*
|
|
* Fire/collection docs use `idGeneration: 'MONGO'`, so their `_id` is a
|
|
* `Mongo.ObjectID`, whose `.toString()` yields `ObjectID("<hex>")` — NOT the
|
|
* bare hex. Interpolating an `_id` straight into a URL or any string therefore
|
|
* produces `.../fire/archive/ObjectID("...")`, which the routes can't match.
|
|
*
|
|
* Use `hexId()` wherever an id becomes part of a string (URLs, comment
|
|
* reference ids, DOM ids). It returns the 24-char hex for an ObjectID and
|
|
* passes plain-string ids through unchanged. Do NOT use it for DDP method
|
|
* args whose `check()` expects `Meteor.Collection.ObjectID` — pass the object.
|
|
*/
|
|
export const hexId = id =>
|
|
(id && typeof id.toHexString === 'function' ? id.toHexString() : id);
|
|
|
|
export default hexId;
|