sorensen / absolutify

Replace relative URLs with absolute in a given HTML string.
MIT License
22 stars 6 forks source link

html attributes in uppercase #9

Open thesandlord opened 4 years ago

thesandlord commented 4 years ago

It seems like attributes in uppercase, for example:

<img SRC="/logo.png">

are not detected.

Is this as intended? Happy to submit a PR to fix this!

thesandlord commented 4 years ago

The workaround is to overwrite the regex with ones that accept uppercase as well:

  var absolutify = require('absolutify')
  absolutify.rx = /((href|src|codebase|cite|background|cite|action|profile|formaction|icon|manifest|archive|HREF|SRC|CODEBASE|CITE|BACKGROUND|CITE|ACTION|PROFILE|FORMACTION|ICON|MANIFEST|ARCHIVE)=["'])(([.]+\/)|(?:\/)|(?=#))(?!\/)/g
  absolutify.captureRx = /((href|src|codebase|cite|background|cite|action|profile|formaction|icon|manifest|archive|HREF|SRC|CODEBASE|CITE|BACKGROUND|CITE|ACTION|PROFILE|FORMACTION|ICON|MANIFEST|ARCHIVE)=["'])((([.]+\/)|(?:\/)|(?:#))(?!\/)[a-zA-Z0-9._-]+)/g