get canonical() {
    if (typeof this._canonical === 'undefined') {
      let canonical = false;

      if (
        this.href &&
        this.from &&
        this.from.assetGraph &&
        this.from.assetGraph.canonicalRoot
      ) {
        // Need to figure out another way to achieve the "slashesDenoteHost"
        // behavior (3rd parameter to urlModule.parse)
        // eslint-disable-next-line n/no-deprecated-api
        const canonicalRootObj = urlModule.parse(
          this.from.assetGraph.canonicalRoot,
          false,
          true
        );

        // Need to figure out another way to achieve the "slashesDenoteHost"
        // behavior (3rd parameter to urlModule.parse)
        // eslint-disable-next-line n/no-deprecated-api
        const hrefObj = urlModule.parse(this.href, false, true);

        canonical =
          hrefObj.slashes === true &&
          ['http:', 'https:', null].includes(hrefObj.protocol) &&
          canonicalRootObj.host === hrefObj.host &&
          hrefObj.path.startsWith(canonicalRootObj.path) &&
          (canonicalRootObj.protocol === hrefObj.protocol ||
            canonicalRootObj.protocol === null);
      }

      this._canonical = canonical;
    }

    return this._canonical;
  }
Get or set the canonical state of a Relation

If [AssetGraph]{@link AssetGraph} has a [`canonicalRoot`]{@link AssetGraph#canonicalRoot}
property, AssetGraph will detect absolute URLs matching `AssetGraph.canonicalRoot`
as if they were of [`hrefType`]{@link Relation#hrefType} `rootRelative`.

The getter tell you if [`Relation.href`]{@link Relation#href} will be prepended
with `Assetgraph.canonicalRoot`.

The setter will change the Relation's `href` to be prefixed with `AssetGraph.canonicalRoot`
if `true`, and without if `false`

@type {Boolean}