Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Unable to parse URL from google font face #8

Open
minhnguyenlinknode opened this issue Jan 17, 2018 · 0 comments
Open

Unable to parse URL from google font face #8

minhnguyenlinknode opened this issue Jan 17, 2018 · 0 comments

Comments

@minhnguyenlinknode
Copy link

I need to parse URLs from this CSS content but it returns nothing:

@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  src: local('Montserrat Regular'), local('Montserrat-Regular'), url(https://fonts.gstatic.com/s/montserrat/v12/rBHvpRWBkgyW99dXT88n7yEAvth_LlrfE80CYdSH47w.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

I have used this code to get URLs:

 var uris = _cssLoader.AllStyleRules
                .SelectMany(styleRule => styleRule.Declaration.AllData)
                .SelectMany(prop => prop.Value.Unit == CssUnit.List ? prop.Value.List : new[] { prop.Value })
                .Where(val => val.Unit == CssUnit.Url)
                // Get unresolved URLs (you can use Uri property to get resolved URLs)
                .Select(val => val.OriginalUri)              
                .ToList();
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant