Skip to content

rewriteUrl can return a local path that can't be used by the URL Constructor #331

@wwahammy

Description

@wwahammy

I'm trying to use web-archive-site-mirror at the page https://lcc-archive.aws.walkerart.org/collections/publications/jazz/creative-black-music-at-the-walker-selections-from-the-archives/. I'm getting a type error in the URL constructor called in initAnchorElemOverride: TypeError: URL constructor: /collections/publications/jazz/creative-black-music-foreword is not a valid URL.

The compiled but unminified code reads as follows

initAnchorElemOverride() {
        const t = Object.getOwnPropertyDescriptor(HTMLAnchorElement.prototype, 'href');
        if (!t?.get) return;
        const e = this,
        r = t.get,
        i = t => {
          const i = Object.getOwnPropertyDescriptor(HTMLAnchorElement.prototype, t);
          if (!i?.set) return;
          const o = i.set;
          Object.defineProperty(
            HTMLAnchorElement.prototype,
            t,
            {
              set(r) {
                const i = new URL(e.rewriteUrl(r));
                return o.call(this, i[t])
              },
              get() {
                return new URL(e.unrewriteUrl(r.call(this))) [t]
              }
            }
          )
        };
        i('href'),
        i('hostname'),
        i('host'),
        i('protocol'),
        i('origin')
      }

The error is happening an the line const i = new URL(e.rewriteUrl(r)); If I work my way backwards, I think this corresponds to

const url = new URL(rw.rewriteUrl(v));
.

I don't understand the code well enough to know what rewriteUrl (or convUrl inside it) SHOULD be returning and why they're returning the wrong thing though 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions