Skip to content

Commit

Permalink
build(docs-infra): be able to resolve root-relative image URLs in `ge…
Browse files Browse the repository at this point in the history
…tImageDimensions()` (#46138)

Previously, `getImageDimensions()` would try to resolve image URLs
relative to the base path using `path.resolve()`. This resulted in
root-relative URLs (i.e. URLs starting with `/`) being treated as
absolute filesystem paths and thus resolving incorrectly
([example failure][1]).

This commit fixes it by using `.join()` instead, which is more
appropriate in this case. (Originally discussed [here][2].)

[1]: https://circleci.com/gh/angular/angular/1173150
[2]: #46134 (comment)

PR Close #46138
  • Loading branch information
gkalpak authored and atscott committed May 26, 2022
1 parent bd6d82b commit 3fdcf99
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('canonical-path');
const { join } = require('canonical-path');
const sizeOf = require('image-size');

module.exports = function getImageDimensions() {
return (basePath, path) => sizeOf(resolve(basePath, path));
return (basePath, path) => sizeOf(join(basePath, path));
};

0 comments on commit 3fdcf99

Please sign in to comment.