websanova / js-url

url() - A simple, lightweight url parser for JavaScript
http://www.websanova.com
MIT License
1.93k stars 204 forks source link

AMD module #54

Closed aripalo closed 7 years ago

aripalo commented 7 years ago

Fixes #50.

If AMD loader is present (basically when (typeof define === 'function' && define.amd !== undefined) is truthy) the script registers itself as anonymous AMD module without polluting global window-object or extending jQuery.

This means that one can use the script by:

require(['http://example.com/url.min.js'], function(privateJsUrl) {
  console.log(typeof window.url); // -> undefined
  console.log(typeof $.url); // -> undefined
  console.log(typeof privateJsUrl); // -> function
  console.log(privateJsUrl('domain', 'http://foo.bar.example.com')); // -> example.com
});
websanova commented 7 years ago

Thx, will take a look at this shortly.

On Feb 9, 2017 02:00, "Ari Palo" notifications@github.com wrote:

Fixes #50 https://github.com/websanova/js-url/issues/50.

If AMD loader is present (basically when (typeof define === 'function' && define.amd !== undefined) is truthy) the script registers itself as anonymous AMD module without polluting global window-object or extending jQuery.

This means that one can use the script by:

require(['http://example.com/url.min.js'], function(privateJsUrl) { console.log(typeof window.url); // -> undefined console.log(typeof $.url); // -> undefined console.log(typeof privateJsUrl); // -> function console.log(privateJsUrl('domain', 'http://foo.bar.example.com')); // -> example.com });


You can view, comment on, or merge this pull request online at:

https://github.com/websanova/js-url/pull/54 Commit Summary

  • add .editorconfig
  • format url.js with editorconfig
  • wrap to IIFE and explicitly assign to window
  • define as AMD module
  • update minified version
  • fix AMD definition
  • describe AMD functionality
  • some text adjustment on README
  • some text adjustment on README
  • some text adjustment on README

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/websanova/js-url/pull/54, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcyySDunH01-Hd8wpNxgX8bjmnE41sks5rahC0gaJpZM4L7OJO .

websanova commented 7 years ago

Ok, this has been pushed up as v2.4.0

websanova commented 7 years ago

Thx, for adding this :-)

oytuntez commented 7 years ago

Can't see v2.4: https://github.com/websanova/js-url/releases

Thus bower installs 2.3.1

websanova commented 7 years ago

Whoops, sorry. Pushed now.

https://github.com/websanova/js-url/releases/tag/v2.4.0

On Thu, Feb 16, 2017 at 5:11 AM, Oytun Tez notifications@github.com wrote:

Can't see v2.4: https://github.com/websanova/js-url/releases

Thus bower installs 2.3.1

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/websanova/js-url/pull/54#issuecomment-280156740, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy2GCaYUeU9g4kiIxB-QoprXXDzNWks5rc3gRgaJpZM4L7OJO .

oytuntez commented 7 years ago

Perfect! Pulling it right away. Fresh release, mmmmmm...