Ability to transform http into https and vice-versa

Created on 3 November 2009, over 15 years ago
Updated 26 November 2024, 7 months ago

An option to transform any http:// src attributes, into https:// depending if the page is being viewed is in https or not. This ensures that nasty warnings don't plague the user in IE.

In my version of this module, I did it like so:

function javascript_bypath_init() {
  global $_javascript_by_path_script;

  if ($rule = _javascript_bypath_path_rule_load()) {
    $_javascript_by_path_script = _javascript_bypath_scripts_load($rule->id);

    if (_javascript_bypath_is_secure()) {
      $value = str_replace('http://', 'https://', $_javascript_by_path_script->script_value);
    }
    else {
      $value = str_replace('https://', 'http://', $_javascript_by_path_script->script_value);
    }
    drupal_add_js(drupal_validate_utf8($_javascript_by_path_script->script_value) ? $_javascript_by_path_script->script_value : '', 'inline', 'footer', FALSE, FALSE, FALSE);
  }
}

function javascript_bypath_footer() {
  global $_javascript_by_path_script;

  if ($_javascript_by_path_script) {
    if (_javascript_bypath_is_secure()) {
      $value = str_replace('http://', 'https://', $_javascript_by_path_script->noscript_value);
    }
    else {
      $value = str_replace('https://', 'http://', $_javascript_by_path_script->noscript_value);
    }

    $value = drupal_validate_utf8($value) ? $value : '';
    return '<noscript>'. $value .'</noscript>';
  }
}

Obviously you would want a config option to turn this feature on/off per rule though.

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain mrfelton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    I'm closing it because the issue was created a long time ago without any further steps.

    if you still need it then raise a new one.
    thanks

Production build 0.71.5 2024