Skip to content

Commit

Permalink
Improve RegExes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocaccamo committed Jan 21, 2025
1 parent 113a16e commit fa80bdf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ function isHttps(url) {
}

function isLocalhost(url) {
const re =
/^(https?\:\/\/)(localhost(.[a-z0-9\-])*|127\.0\.0\.1)(\:[\d]+)?(\/(.)*)?$/;
const re = /^(https?:\/\/)(localhost(\.[a-z0-9-]+)*|127\.0\.0\.1)(:\d+)?(\/.*)?$/i;
return re.test(url || getURL());
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// };

function removeNamespaces(str) {
return str.replace(/(\<(.|\n)+?\>)/g, (tag) => {
return tag.replace(/(\s|\<\/?){1}([\w]+\:){1}/g, '$1');
return str.replace(/<[^>]*>/g, (tag) => {
return tag.replace(/(\s|<\/?)[a-zA-Z0-9]+\:/g, '$1');
});
}

Expand Down

0 comments on commit fa80bdf

Please sign in to comment.