mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-25 15:17:23 +00:00
feat(apps): puter.apps.get() accepts a URL (#4686)
A string containing :// is looked up as a URL instead of a name. The puter-apps driver's read takes id.url and resolves it through appUidFromOrigin, so it returns the same app a page on that origin acts as.
This commit is contained in:
1 parent
6b7541d0b6
commit
327eef2d32
9 files changed
+199
-8
No files matched your search
@@ -173,6 +173,32 @@ export default suite('apps', {
|
||||
);
|
||||
},
|
||||
|
||||
'get with a URL returns the app at its origin': async (t) => {
|
||||
const app = await t.puter.apps.create(
|
||||
'apps-suite-by-url',
|
||||
'https://apps-suite-by-url.example.com/',
|
||||
);
|
||||
const fetched = await t.puter.apps.get(
|
||||
'https://apps-suite-by-url.example.com/about?tab=1',
|
||||
);
|
||||
t.assert.equal(fetched.uid, app.uid);
|
||||
t.assert.equal(fetched.name, 'apps-suite-by-url');
|
||||
},
|
||||
|
||||
'get with a URL no app serves rejects with not_found': async (t) => {
|
||||
const error = (await t.assert.rejects(() =>
|
||||
t.puter.apps.get('https://apps-suite-no-app.example.com/'),
|
||||
)) as { code?: string };
|
||||
t.assert.equal(error.code, 'not_found');
|
||||
},
|
||||
|
||||
'get with a URL that is not a web URL rejects with bad_request': async (t) => {
|
||||
const error = (await t.assert.rejects(() =>
|
||||
t.puter.apps.get('file:///index.html'),
|
||||
)) as { code?: string };
|
||||
t.assert.equal(error.code, 'bad_request');
|
||||
},
|
||||
|
||||
'delete removes the app': async (t) => {
|
||||
await t.puter.apps.create(
|
||||
'apps-suite-delete',
|
||||
|
||||
Reference in new issue
Block a user