Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/extension/url-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ export function isSharePointHost(url, projects = []) {
});
}

/**
* Determines if a URL is a personal OneDrive folder.
* @param {string} url The tab URL
* @returns {boolean} {@code true} if personal OneDrive folder, else {@code false}
*/
export function isPersonalOneDriveFolder(url) {
const { pathname } = new URL(url);
return pathname.toLowerCase().endsWith('/onedrive.aspx')
|| [
'/personal/',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add /my too no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'/:f:/r/personal/',
'/:f:/p/',
].some((prefix) => pathname.startsWith(prefix));
}

/**
* Determines if a URL has a Google Drive host.
* @param {string} url The tab URL
Expand Down Expand Up @@ -219,7 +234,9 @@ class UrlCache {
urlCache.push(entry);
}
} else {
const isSPHost = isSharePointHost(url, Array.isArray(config) ? config : [config]);
const isSPHost = isSharePointHost(url, Array.isArray(config) ? config : [config])
&& !isPersonalOneDriveFolder(url); // no lookup for personal folders

// lookup (for sharepoint and google drive only)
if (!isSPHost && !isGoogleDriveHost(url)) {
return;
Expand Down
18 changes: 18 additions & 0 deletions test/url-cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import sinon from 'sinon';
import chromeMock from './mocks/chrome.js';
import {
isSharePointHost,
isPersonalOneDriveFolder,
urlCache,
} from '../src/extension/url-cache.js';
import {
Expand Down Expand Up @@ -53,6 +54,23 @@ describe('Test url-cache', () => {
)).to.be.true;
});

it('isPersonalOneDriveFolder', async () => {
// sharepoint folder
expect(isPersonalOneDriveFolder(
'https://acme.sharepoint.com/sites/ACME/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2FACME%2FShared%20Documents%2Ffoo&viewid=07cb4d37%2D3ae2%2D4762%2D87ef%2D5ad0e1059258',
)).to.be.false;
// personal onedrive folders
expect(isPersonalOneDriveFolder(
'https://acme-my.sharepoint.com/personal/someone_acme_com/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fsomeone_acme_com2FDocuments&view=0',
)).to.be.true;
expect(isPersonalOneDriveFolder(
'https://acme-my.sharepoint.com/:f:/r/personal/someone_acme_com/Documents/ACME',
)).to.be.true;
expect(isPersonalOneDriveFolder(
'https://acme-my.sharepoint.com/:f:/p/someone/EoYJVIqcrKFHu1NVLXhq9c8BZx8zwWqfEtGZ1otwW9W0mQ?e=kuqPBr',
)).to.be.true;
});

describe('set', () => {
let fetchMock;
let sessionSet;
Expand Down