(core) Treating API urls as external in cells

Summary:
Links for the API endpoints in a cell didn't work as they were interpreted as
internal routes. Now they are properly detected as external.

Test Plan: Added new test

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D4078
This commit is contained in:
Jarosław Sadziński
2023-10-17 18:31:33 +02:00
parent 77726849ad
commit 69d5ee53a8
5 changed files with 50 additions and 8 deletions

View File

@@ -90,6 +90,12 @@ describe('gristUrlState', function() {
// Billing routes
assert.deepEqual(prod.decodeUrl(new URL('https://bar.example.com/o/baz/billing')),
{org: 'baz', billing: 'billing'});
// API routes
assert.deepEqual(prod.decodeUrl(new URL('https://bar.example.com/api/docs/bar')),
{org: 'bar', doc: 'bar', api: true});
assert.deepEqual(prod.decodeUrl(new URL('http://localhost:8080/o/baz/api/docs/bar')),
{org: 'baz', doc: 'bar', api: true});
});
it('should decode query strings in URLs correctly', function() {
@@ -139,6 +145,11 @@ describe('gristUrlState', function() {
// Billing routes
assert.equal(prod.encodeUrl({org: 'baz', billing: 'billing'}, hostBase),
'https://baz.example.com/billing');
// API routes
assert.equal(prod.encodeUrl({org: 'baz', doc: 'bar', api: true}, hostBase), 'https://baz.example.com/api/docs/bar');
assert.equal(prod.encodeUrl({org: 'baz', doc: 'bar', api: true}, localBase),
'http://localhost:8080/o/baz/api/docs/bar');
});
it('should encode state in billing URLs correctly', function() {