mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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]: https://github.com/angular/angular/pull/46134#issuecomment-1137191996 PR Close #46138
6 lines
194 B
JavaScript
6 lines
194 B
JavaScript
const { join } = require('canonical-path');
|
|
const sizeOf = require('image-size');
|
|
|
|
module.exports = function getImageDimensions() {
|
|
return (basePath, path) => sizeOf(join(basePath, path));
|
|
};
|