We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e83022d commit 050f5f6Copy full SHA for 050f5f6
src/commands/dev-env-sync-sql.ts
@@ -45,11 +45,11 @@ function stripProtocol( url: string ): string {
45
* @return Site home url. null if not found
46
*/
47
function findSiteHomeUrl( sql: string ): string | null {
48
- const regex = `['"](siteurl|home)['"],\\s?['"](.*?)['"]`;
49
- const url = sql.match( regex )?.[ 2 ] || '';
+ const regex = /(['"])(?:siteurl|home)\1,\s?\1([Hh][Tt][Tt][Pp][Ss]?:\/\/.+?)\1/;
+ const url = regex.exec( sql )?.[ 2 ] ?? '';
50
try {
51
- new URL( url );
52
- return url;
+ const parsed = new URL( url );
+ return parsed.hostname ? url : null;
53
} catch {
54
return null;
55
}
0 commit comments