ProductOpener::URL - generates the URL of the product
ProductOpener::URL
is used to generate a URL of the product according to the subdomain .
use ProductOpener::URL qw/:all/; my $image = "$BASE_DIRS{PRODUCTS_IMAGES}/$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"]
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.
format_subdomain()
returns URL on the basis of subdomain and scheme (http/https)
A scalar variable to indicate the subdomain (e.g. "us" or "static") needs to be passed as an argument.
Defaults to the current server product type. If passed, use the domain for that product type. (e.g. "beauty" -> "openbeautyfacts.org")
The function returns a URL by concatenating scheme, subdomain and server-domain.
subdomain_supports_https()
determines if the subdomain supports https.
A scalar variable to indicate the subdomain (e.g. "us" or "static") needs to be passed as an argument.
The function returns true after evaluating the true value for the regular expression using grep or subdomain, ssl_subdomains