diff --git a/migrations/20141021192552-db-create.js b/migrations/20141021192552-db-create.js index 8a6c54ae1..186096421 100644 --- a/migrations/20141021192552-db-create.js +++ b/migrations/20141021192552-db-create.js @@ -1,9 +1,7 @@ 'use strict'; -var url = require('node:url'); - exports.up = function(db, callback) { - var dbName = url.parse(process.env.DATABASE_URL).path.substr(1); // remove slash + var dbName = new URL(process.env.DATABASE_URL).pathname.slice(1); // remove slash // by default, mysql collates case insensitively. 'utf8_general_cs' is not available db.runSql('ALTER DATABASE ' + dbName + ' DEFAULT CHARACTER SET=utf8 DEFAULT COLLATE utf8_bin', callback); diff --git a/migrations/20170414193114-database-utf8mb4.js b/migrations/20170414193114-database-utf8mb4.js index 7464e80eb..36fca0dc8 100644 --- a/migrations/20170414193114-database-utf8mb4.js +++ b/migrations/20170414193114-database-utf8mb4.js @@ -1,9 +1,7 @@ 'use strict'; -var url = require('node:url'); - exports.up = function(db, callback) { - var dbName = url.parse(process.env.DATABASE_URL).path.substr(1); // remove slash + var dbName = new URL(process.env.DATABASE_URL).pathname.slice(1); // remove slash // by default, mysql collates case insensitively. 'utf8_general_cs' is not available db.runSql('ALTER DATABASE ' + dbName + ' DEFAULT CHARACTER SET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci', callback); diff --git a/src/oidcserver.js b/src/oidcserver.js index 1f6b8ff7a..2534c9c6e 100644 --- a/src/oidcserver.js +++ b/src/oidcserver.js @@ -27,7 +27,6 @@ import safe from 'safetydance'; import settings from './settings.js'; import superagent from '@cloudron/superagent'; import tokens from './tokens.js'; -import url from 'node:url'; import users from './users.js'; import groups from './groups.js'; import util from 'node:util'; @@ -143,7 +142,7 @@ class StorageAdapter { // native callbacks for apps have custom schema like app.immich:/ tmp.redirect_uris = []; client.loginRedirectUri.split(',').map(s => s.trim()).forEach((s) => { - if (url.parse(s).protocol) tmp.redirect_uris.push(s); + if (URL.canParse(s)) tmp.redirect_uris.push(s); else tmp.redirect_uris = tmp.redirect_uris.concat(domains.map(fqdn => `https://${fqdn}${s}`)); }); } else { diff --git a/src/routes/test/cloudron-test.js b/src/routes/test/cloudron-test.js index aafc9de75..082f30d2c 100644 --- a/src/routes/test/cloudron-test.js +++ b/src/routes/test/cloudron-test.js @@ -3,7 +3,6 @@ import constants from '../../constants.js'; import common from './common.js'; import assert from 'node:assert/strict'; import superagent from '@cloudron/superagent'; -import url from 'node:url'; describe('Cloudron', function () { @@ -65,7 +64,7 @@ describe('Cloudron', function () { const response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`) .send({ - inviteToken: url.parse(response2.body.inviteLink, true).query.inviteToken, + inviteToken: new URL(response2.body.inviteLink).searchParams.get('inviteToken'), password, username, displayName }) .ok(() => true); @@ -104,7 +103,7 @@ describe('Cloudron', function () { const response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`) .send({ - inviteToken: url.parse(response2.body.inviteLink, true).query.inviteToken, + inviteToken: new URL(response2.body.inviteLink).searchParams.get('inviteToken'), password, username: 'setupuser2', // this will cause a conflict. cannot change username displayName @@ -114,7 +113,7 @@ describe('Cloudron', function () { const response4 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`) .send({ - inviteToken: url.parse(response2.body.inviteLink, true).query.inviteToken, + inviteToken: new URL(response2.body.inviteLink).searchParams.get('inviteToken'), password, displayName }) @@ -158,7 +157,7 @@ describe('Cloudron', function () { let response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`) .send({ - inviteToken: url.parse(response2.body.inviteLink, true).query.inviteToken, + inviteToken: new URL(response2.body.inviteLink).searchParams.get('inviteToken'), password, username, // cannot set username when profile is locked }) @@ -167,7 +166,7 @@ describe('Cloudron', function () { response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`) .send({ - inviteToken: url.parse(response2.body.inviteLink, true).query.inviteToken, + inviteToken: new URL(response2.body.inviteLink).searchParams.get('inviteToken'), password, }) .ok(() => true);