Skip to content

Commit

Permalink
Wrap IPv6 address in brackets [ ] if needed (#36)
Browse files Browse the repository at this point in the history
* Use db_port

This is one puzzle piece for joomla/joomla-cms#43902

* Wrap IPv6 in brackets [ ] if port is specified.

If a port number is provided, wrap IPv6 addresses with square brackets [ ].

* No square brackets for IPv6 address for PostgreSQL

* installJoomla for stable releases (#35)

* Update README.md (#32)

* Update README.md

Correcting image file name

* Use absolute URL to see image in NPM README too

* Square brackets on pgsql IPv6 addresses with port
  • Loading branch information
muhme authored Oct 20, 2024
1 parent 8240e46 commit 9dee4e5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/joomla.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ const joomlaCommands = () => {
cy.get('#jform_admin_email').type(config.email)
cy.get('#step2').click()

// Fill database configuration
// Fill database connection settings
let connection = config.db_host
if (config.db_port && config.db_port.trim() !== "") {
// host:port currently (August 2024) only work for MariaDB and MySQL
const isPortSet = config.db_port && config.db_port.trim() !== "";
// If the host is an IPv6 address, not already in square brackets,
// and it's not PostgreSQL without a port number, add square brackets around it.
if (connection.split(':').length > 2 && !connection.includes('[') &&
(isPortSet || (config.db_type !== 'PostgreSQL (PDO)') && (config.db_type !== 'pgsql'))) {
// MariaDB and MySQL require square brackets around IPv6 addresses, even if no port is set
// For PostgreSQL, square brackets are used only if a port number is provided
// (see PR https://github.com/joomla-framework/database/pull/315)
connection = `[${connection}]`;
}
if (isPortSet) {
connection += `:${config.db_port.trim()}`;
}
cy.get('#jform_db_type').select(config.db_type)
cy.get('#jform_db_host').clear().type(connection)
cy.get('#jform_db_user').type(config.db_user)

if (config.db_password) {
cy.get('#jform_db_pass').type(config.db_password)
}
Expand Down

0 comments on commit 9dee4e5

Please sign in to comment.