Shop: Servernamen entweder mit Protokoll speichern oder Protokoll ergänzen
authorJan Büren <jan@kivitendo.de>
Wed, 9 Feb 2022 09:22:00 +0000 (10:22 +0100)
committerJan Büren <jan@kivitendo.de>
Fri, 11 Feb 2022 14:19:57 +0000 (15:19 +0100)
SL/DB/Shop.pm
SL/ShopConnector/Shopware6.pm

index 55f81e5..c5e652a 100644 (file)
@@ -21,7 +21,8 @@ sub validate {
   push @errors, $::locale->text('The path is missing.')        unless $self->{path};
   push @errors, $::locale->text('The Host Name is missing')    unless $self->{server};
   push @errors, $::locale->text('The Host Name seems invalid') unless $self->{server} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
-  push @errors, $::locale->text('The Proxy Name seems invalid') unless $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
+  push @errors, $::locale->text('The Protocol for Host Name seems invalid (expected: http:// or https://)!')
+                                                               if ($self->{server} =~ m/:/ && $self->{server} !~ m/(^https:\/\/|^http:\/\/)/);
   push @errors, $::locale->text('The Proxy Name seems invalid') . $self->{proxy} . ':' unless !$self->{proxy} ||  $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
   push @errors, $::locale->text('Orders to fetch neeeds a positive Integer')
                                                                unless $self->{orders_to_fetch} > 0;
index 38ec37f..bd54329 100644 (file)
@@ -709,10 +709,10 @@ sub set_orderstatus {
 sub init_connector {
   my ($self) = @_;
 
-  my $client = REST::Client->new(host => $self->config->server);
+  my $protocol = $self->config->server =~ /(^https:\/\/|^http:\/\/)/ ? '' : $self->config->protocol . '://';
+  my $client   = REST::Client->new(host => $protocol . $self->config->server);
 
   $client->getUseragent()->proxy([$self->config->protocol], $self->config->proxy) if $self->config->proxy;
-
   $client->addHeader('Content-Type', 'application/json');
   $client->addHeader('charset',      'UTF-8');
   $client->addHeader('Accept',       'application/json');