Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astro.resolve #1085

Merged
merged 9 commits into from
Aug 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rename nonRelative and better match
  • Loading branch information
matthewp committed Aug 16, 2021
commit 9fc2aad4ce03f8d6e21c44f141773afa7610c7b1
4 changes: 2 additions & 2 deletions packages/astro/src/compiler/codegen/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const warnableRelativeValues = new Set([
'source+srcset'
]);

const nonRelative = /^(?!(https?:|data:|\/))/;
const matchesRelative = /^(?![A-Za-z][+-.0-9A-Za-z]*:|\/)/;

export function warnIfRelativeStringLiteral(logging: LogOptions, nodeName: string, attr: Attribute, value: string) {
let key = nodeName + '+' + attr.name;
if(warnableRelativeValues.has(key) && nonRelative.test(value)) {
if(warnableRelativeValues.has(key) && matchesRelative.test(value)) {
let message = `This value will be resolved relative to the page: <${nodeName} ${attr.name}="${value}">`;
warn(logging, 'relative-link', message);
}
Expand Down