Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the ProductOpener::URL.pm module #3046

Merged
merged 3 commits into from
Mar 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions lib/ProductOpener/URL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


=head1 NAME

ProductOpener::URL - generates the URL of the product

=head1 SYNOPSIS

C<ProductOpener::URL> is used to generate a URL of the product according to the subdomain .

use ProductOpener::URL qw/:all/;

my $image = "$www_root/images/products/$path/$filename.full.jpg";
my $image_url = format_subdomain('static') . "/images/products/$path/$filename.full.jpg";

# subdomain format:
# [2 letters country code or "world" or "static"]

=head1 DESCRIPTION

The module implements the URL generation
on the basis of subdomain format which can be country code, world or static and on the basis of subdomain's support for https or http.

=cut

package ProductOpener::URL;

use utf8;
Expand All @@ -42,6 +66,22 @@ use experimental 'smartmatch';

use ProductOpener::Config qw/:all/;

=head1 FUNCTIONS

=head2 format_subdomain( SUBDOMAIN )

C<format_subdomain()> returns URL on the basis of subdomain and scheme (http/https)

=head3 Arguments

A scalar variable to indicate the subdomain (e.g. "us" or "static") needs to be passed as an argument.

=head3 Return Values

The function returns a URL by concatenating scheme, subdomain and server-domain.

=cut

sub format_subdomain {

my ($sd) = @_;
Expand All @@ -59,6 +99,20 @@ sub format_subdomain {

}

=head2 subdomain_supports_https( SUBDOMAIN )

C<subdomain_supports_https()> determines if the subdomain supports https.

=head3 Arguments

A scalar variable to indicate the subdomain (e.g. "us" or "static") needs to be passed as an argument.

=head3 Return Values

The function returns true after evaluating the true value for the regular expression using grep or subdomain, ssl_subdomains

=cut

sub subdomain_supports_https {

my ($sd) = @_;
Expand Down