Skip to content

[bug] fetchModel fails when host and cqPath is passed #288

@arunpadmasreede

Description

@arunpadmasreede

Describe the bug
fetchModel functions failes to get the model when host and cqPath are passed as the url formed to fetch is incorrect

Package version
v2.1.0

To Reproduce
Steps to reproduce the behavior:

  1. invoke fetchModel({
    cqPath,
    host
    })
    where cqPath can be any path which can give json
    and host where this can be used
    example : fetch('https:/api.mockfly.dev/mocks/1a7495c9-1442-415f-b55c-5f5b3a2ed5f4/my-iqos-header.model.json')

Expected behavior
The fetch url should be correctly formed and work as expected to download json
in fetchModel.ts at line 58
const hostURL = sanitizeUrl(${host}/${path}).replace(//+/g, '/'); is the one causing the problem of replacing https:// to http:/ and due to which fetch for model.json fails
Better to replace this with
const fullUrl = new URL(cqPath, host).toString(); which gives the correct url

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions