adobe/helix-onedrive-support

getDriveItemFromShareLink returns no details if link has format `/drives/...`

dominique-pfister opened this issue · 2 comments

In OneDrive.getDriveItemFromShareLink:

async getDriveItemFromShareLink(sharingUrl) {
let driveItem = OneDrive.driveItemFromURL(sharingUrl);
if (driveItem) {
return driveItem;
}

if the link given starts with /drives/..., only very basic information is returned (id and parentReference), as opposed to when that link starts with https://. I see no way to get more information on the item (e.g. its last modified date) in the former case.

I suggest to either retrieve the information before returning from getDriveItemFromShareLink or add an optional parameter (e.g. fetchInfo = false) that fills the missing information. That information is returned from:

https://graph.microsoft.com/v1.0/drives/<drive-id>/items/<item-id>

This feature would particularly help in solving adobe/helix-data-embed#233

this shortcut is to avoid an extra roundtrip if not needed. since the users of this api need to fetch the item anyways, they'll have all the information they need.

OneDrive.getDriveItem() works as suggested, API change not required.