Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Absolute marker URLs fail to load: nftMarkerUrls.push is not a function

Open
#367 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
67/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend, web-dev

Research direction

Start by reading the URL handling in src/Worker.ts and src/Worker.simd.ts, then check the README Configuration section's addPath row. Exercise absolute and relative marker URLs and cameraPara with and without addPath, using the documented loading debug logs to compare behavior. Done means both workers handle those cases as specified, dist/ and types/ are rebuilt, and the README note is updated.

Written by the indexing model from the issue text.

Description

bug

Bug

Marker paths given as absolute http(s) URLs cannot be loaded. When addPath is empty, the worker assigns the URL to the list instead of adding it, and then throws:

TypeError: nftMarkerUrls.push is not a function

(minified: C.push is not a function, as reported in #278).

In src/Worker.ts, and the same in src/Worker.simd.ts:

let nftMarkerUrls: Array<string> = [];
// ...
const reM = regexM.test(msg.marker);

for (let i = 0; i < markerLength; i++) {
    let nftMarkerUrl: string;
    if (reM == true) {
        if (msg.addPath) {
            nftMarkerUrl = basePath + "/" + msg.addPath + "/" + msg.marker[i];
        } else {
            nftMarkerUrls = msg.marker[i]; // replaces the array with a string
        }
    } else if (reM == false) {
        // ...
    }
    nftMarkerUrls.push(nftMarkerUrl); // TypeError
}

msg is untyped, so TypeScript does not catch the assignment.

Related problems in the same code

  • addPath is added to absolute URLs too. With addPath set, both the marker paths and cameraPara become origin + "/" + addPath + "/" + path even when the path is already an absolute URL, which gives an invalid address. #366 documents this in the README (leave addPath empty with absolute URLs) as a workaround.
  • One check for the whole list. regexM.test(msg.marker) runs once on the whole array (converted to a comma-separated string), so a list mixing relative paths and absolute URLs is handled as if all paths were absolute.

Suggested fix

Resolve each path on its own, with one helper for both the markers and cameraPara:

  • an absolute http(s) URL is used as is, whatever addPath is;
  • a relative path keeps the current behaviour: origin/addPath/path, or origin/path without addPath.

Apply the same change to Worker.simd.ts, rebuild dist/ and types/, and update the addPath row in the README's Configuration section, which will no longer need the "leave it empty" note.

How to check

  • ARnft.init(...) with a marker on another origin, e.g. https://raw.githack.com/webarkit/ARnft/master/examples/DataNFT/pinball, and no addPath: the marker loads and tracks;
  • the same with addPath set: the absolute URL is not prefixed;
  • relative markers and cameraPara, with and without addPath: same URLs as today (see the Loading NFT marker at: and Loading camera at: debug logs).

Fixing this should also close #278.

Dominant language
TypeScript
Stars
235
Forks
50
Avg merge
11h 4m
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from webarkit/ARnft

All issues in webarkit/ARnft

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.