Skip to content

fix: update isUri() to compare fsPath as string - #114972

Merged
Johannes Rieken (jrieken) merged 1 commit into
microsoft:masterfrom
enagic:master
Jan 26, 2021
Merged

Johannes Rieken (jrieken) merged 1 commit into
microsoft:masterfrom
enagic:master

Conversation

@enagic

@enagic enagic commented Jan 26, 2021

Copy link
Copy Markdown
Contributor

This PR fixes #114971

It looks like typeof thing.fsPath === 'function' should really be typeof thing.fsPath === 'string', since URI.fsPath is a getter.

class URI {
    static isUri(thing) {
        if (thing instanceof URI) {
            return true;
        }
        if (!thing) {
            return false;
        }

        // The code below will likely never be executed in VSCode since `thing instanceof URI === true`
        // but it may happen in monaco-editor.

        return typeof thing.authority === 'string'
            && typeof thing.fragment === 'string'
            && typeof thing.path === 'string'
            && typeof thing.query === 'string'
            && typeof thing.scheme === 'string'
            && typeof thing.fsPath === 'function' // this guy right here should be 'string'
            && typeof thing.with === 'function'
            && typeof thing.toString === 'function';
    }
}

@jrieken
Johannes Rieken (jrieken) merged commit 09ef373 into microsoft:master Jan 26, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in URI.isUri() that fails thing type comparison

2 participants