Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-50456

url.relativeUrl is not working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9, 3.0
    • Fix Version/s: 2.9.1
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide

      Add this code to the bottom of admin/index.php

      (Immediately after the call to admin_externalpage_setup)

      $PAGE->requires->js_amd_inline('
          require(["core/url"], function(url) {
              console.log(url.relativeUrl("/admin/index.php"));
          });
      ');
      

      Go to admin/index.php

      Check your JS console and you should see the full url of the current page.

      You should not see:

      Error: relativeUrl function does not accept absolute urls

      Show
      Add this code to the bottom of admin/index.php (Immediately after the call to admin_externalpage_setup) $PAGE->requires->js_amd_inline(' require(["core/url"], function(url) { console.log(url.relativeUrl("/admin/index.php")); }); '); Go to admin/index.php Check your JS console and you should see the full url of the current page. You should not see: Error: relativeUrl function does not accept absolute urls
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-50456-master

      Description

      The following JS does not work (and it should).

      require(['core/url'], function(url)

      { console.log(url.relativeUrl('/admin/index.php')); }

      );

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                6/Jul/15