Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Oct 17, 2023
1 parent b8377ab commit f0ff8dc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/apidom-reference/src/util/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,12 @@ export const sanitize = (uri: string) => {
return fromFileSystemPath(toFileSystemPath(uri));
}

let returnUri;

try {
returnUri = new URL(uri).toString();
} catch (e) {
return new URL(uri).toString();
} catch {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI#encoding_for_ipv6
returnUri = encodeURI(decodeURI(uri)).replace(/%5B/g, '[').replace(/%5D/g, ']');
return encodeURI(decodeURI(uri)).replace(/%5B/g, '[').replace(/%5D/g, ']');
}

return returnUri;
};

/**
Expand Down

0 comments on commit f0ff8dc

Please sign in to comment.