@@ -141,10 +141,10 @@ const create = async function (req, res, next) {
141141 try {
142142 let result = await db . insertOne ( newObject )
143143 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
144- res . location ( newObject [ "@id" ] )
145- res . status ( 201 )
146144 newObject = idNegotiation ( newObject )
147145 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
146+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
147+ res . status ( 201 )
148148 res . json ( newObject )
149149 }
150150 catch ( error ) {
@@ -305,10 +305,10 @@ const putUpdate = async function (req, res, next) {
305305 if ( alterHistoryNext ( originalObject , newObject [ "@id" ] ) ) {
306306 //Success, the original object has been updated.
307307 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
308- res . location ( newObject [ "@id" ] )
309- res . status ( 200 )
310308 newObject = idNegotiation ( newObject )
311309 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
310+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
311+ res . status ( 200 )
312312 res . json ( newObject )
313313 return
314314 }
@@ -362,10 +362,10 @@ async function _import(req, res, next) {
362362 try {
363363 let result = await db . insertOne ( newObject )
364364 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
365- res . location ( newObject [ "@id" ] )
366- res . status ( 200 )
367365 newObject = idNegotiation ( newObject )
368366 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
367+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
368+ res . status ( 200 )
369369 res . json ( newObject )
370370 }
371371 catch ( error ) {
@@ -438,10 +438,10 @@ const patchUpdate = async function (req, res, next) {
438438 //Then you aren't actually changing anything...only @id came through
439439 //Just hand back the object. The resulting of patching nothing is the object unchanged.
440440 res . set ( utils . configureWebAnnoHeadersFor ( originalObject ) )
441- res . location ( originalObject [ "@id" ] )
442- res . status ( 200 )
443441 originalObject = idNegotiation ( originalObject )
444442 originalObject . new_obj_state = JSON . parse ( JSON . stringify ( originalObject ) )
443+ res . location ( originalObject [ _contextid ( originalObject [ "@context" ] ) ? "id" :"@id" ] )
444+ res . status ( 200 )
445445 res . json ( originalObject )
446446 return
447447 }
@@ -461,10 +461,10 @@ const patchUpdate = async function (req, res, next) {
461461 if ( alterHistoryNext ( originalObject , newObject [ "@id" ] ) ) {
462462 //Success, the original object has been updated.
463463 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
464- res . location ( newObject [ "@id" ] )
465- res . status ( 200 )
466464 newObject = idNegotiation ( newObject )
467465 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
466+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
467+ res . status ( 200 )
468468 res . json ( newObject )
469469 return
470470 }
@@ -552,10 +552,10 @@ const patchSet = async function (req, res, next) {
552552 //Then you aren't actually changing anything...there are no new properties
553553 //Just hand back the object. The resulting of setting nothing is the object from the request body.
554554 res . set ( utils . configureWebAnnoHeadersFor ( originalObject ) )
555- res . location ( originalObject [ "@id" ] )
556- res . status ( 200 )
557555 originalObject = idNegotiation ( originalObject )
558556 originalObject . new_obj_state = JSON . parse ( JSON . stringify ( originalObject ) )
557+ res . location ( originalObject [ _contextid ( originalObject [ "@context" ] ) ? "id" :"@id" ] )
558+ res . status ( 200 )
559559 res . json ( originalObject )
560560 return
561561 }
@@ -572,10 +572,10 @@ const patchSet = async function (req, res, next) {
572572 if ( alterHistoryNext ( originalObject , newObject [ "@id" ] ) ) {
573573 //Success, the original object has been updated.
574574 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
575- res . location ( newObject [ "@id" ] )
576- res . status ( 200 )
577575 newObject = idNegotiation ( newObject )
578576 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
577+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
578+ res . status ( 200 )
579579 res . json ( newObject )
580580 return
581581 }
@@ -665,10 +665,10 @@ const patchUnset = async function (req, res, next) {
665665 //Then you aren't actually changing anything...no properties in the request body were removed from the original object.
666666 //Just hand back the object. The resulting of unsetting nothing is the object.
667667 res . set ( utils . configureWebAnnoHeadersFor ( originalObject ) )
668- res . location ( originalObject [ "@id" ] )
669- res . status ( 200 )
670668 originalObject = idNegotiation ( originalObject )
671669 originalObject . new_obj_state = JSON . parse ( JSON . stringify ( originalObject ) )
670+ res . location ( originalObject [ _contextid ( originalObject [ "@context" ] ) ? "id" :"@id" ] )
671+ res . status ( 200 )
672672 res . json ( originalObject )
673673 return
674674 }
@@ -688,10 +688,10 @@ const patchUnset = async function (req, res, next) {
688688 if ( alterHistoryNext ( originalObject , newObject [ "@id" ] ) ) {
689689 //Success, the original object has been updated.
690690 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
691- res . location ( newObject [ "@id" ] )
692- res . status ( 200 )
693691 newObject = idNegotiation ( newObject )
694692 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
693+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
694+ res . status ( 200 )
695695 res . json ( newObject )
696696 return
697697 }
@@ -786,9 +786,9 @@ const overwrite = async function (req, res, next) {
786786 //result didn't error out, the action was not performed. Sometimes, this is a neutral thing. Sometimes it is indicative of an error.
787787 }
788788 res . set ( utils . configureWebAnnoHeadersFor ( newObject ) )
789- res . location ( newObject [ "@id" ] )
790789 newObject = idNegotiation ( newObject )
791790 newObject . new_obj_state = JSON . parse ( JSON . stringify ( newObject ) )
791+ res . location ( newObject [ _contextid ( newObject [ "@context" ] ) ? "id" :"@id" ] )
792792 res . json ( newObject )
793793 return
794794 }
@@ -901,10 +901,10 @@ const release = async function (req, res, next) {
901901 //result didn't error out, the action was not performed. Sometimes, this is a neutral thing. Sometimes it is indicative of an error.
902902 }
903903 res . set ( utils . configureWebAnnoHeadersFor ( releasedObject ) )
904- res . location ( releasedObject [ "@id" ] )
905904 console . log ( releasedObject . _id + " has been released" )
906905 releasedObject = idNegotiation ( releasedObject )
907906 releasedObject . new_obj_state = JSON . parse ( JSON . stringify ( releasedObject ) )
907+ res . location ( releasedObject [ _contextid ( releasedObject [ "@context" ] ) ? "id" :"@id" ] )
908908 res . json ( releasedObject )
909909 return
910910 }
@@ -966,8 +966,8 @@ const id = async function (req, res, next) {
966966 res . set ( "Cache-Control" , "max-age=86400, must-revalidate" )
967967 //Support requests with 'If-Modified_Since' headers
968968 res . set ( utils . configureLastModifiedHeader ( match ) )
969- res . location ( match [ "@id" ] )
970969 match = idNegotiation ( match )
970+ res . location ( _contextid ( match [ "@context" ] ) ? match . id : match [ "@id" ] )
971971 res . json ( match )
972972 return
973973 }
@@ -2357,4 +2357,4 @@ export default {
23572357 _gog_glosses_from_manuscript,
23582358 _gog_fragments_from_manuscript,
23592359 idNegotiation
2360- }
2360+ }
0 commit comments