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

Bump socket.io-parser from 3.3.0 to 3.3.3 #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion addon/helpers/href-to.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Helper from "@ember/component/helper";
import { getOwner } from "@ember/application";
import { isPresent } from "@ember/utils";

export function hrefTo(context, params) {
let routing = getOwner(context).lookup("service:-routing");
Expand All @@ -16,7 +17,10 @@ function getParamsForGenerateURL(params) {
} else {
queryParams = {};
}
let models = params; // the remainder are the models

// Filter out any items that aren't present
let models = params.filter(item => isPresent(item)); // the remainder are the models

return [targetRouteName, models, queryParams];
}

Expand Down
50 changes: 49 additions & 1 deletion addon/href-to.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Ember from "ember";
import LinkComponent from '@ember/routing/link-component';
import { isPresent } from "@ember/utils";

export default class {

Expand All @@ -12,7 +14,12 @@ export default class {

maybeHandle() {
if (this.shouldHandle()) {
this.handle();
return this.handle();
}

// Add extra check for native app behaviour
if (this.shouldHandleAsExternalNativeLink()) {
return this.handleAsExternalNativeLink();
}
}

Expand All @@ -26,12 +33,41 @@ export default class {
this.recognizeUrl();
}

shouldHandleAsExternalNativeLink() {
return this.isUnmodifiedLeftClick() &&
this.isNotIgnored() &&
this.hasNoActionHelper() &&
this.hasNoDownload() &&
this.isNotLinkComponent() &&

// Additional checks
this.hasUrl() &&
this.isNativeBuild() && // For native app builds only
!this.recognizeUrl(); // Confirm its not an internal link
}

// Standard ember-href-to behavour
handle() {
let router = this._getRouter();
router.transitionTo(this.getUrlWithoutRoot());
this.event.preventDefault();
}

/*
* In order to open external links in the mobile devices system browser, we need to
* pass '_system' through to the open method. This method has been overwritten by the
* cordova inappbrowser plugin so external links can successfully "escape" the webview
* on IOS (Works on android as well, although not explicitly required).
*/
handleAsExternalNativeLink() {
window.open(this.url, '_system');
this.event.preventDefault();
}

hasUrl() {
return isPresent(this.url);
}

isUnmodifiedLeftClick() {
let e = this.event;

Expand Down Expand Up @@ -83,6 +119,10 @@ export default class {
return didRecognize;
}

isNativeBuild() {
return this._getPlatformService().isNativeBuild;
}

getUrlWithoutRoot() {
let url = this.url;
let rootUrl = this._getRootUrl();
Expand All @@ -93,10 +133,18 @@ export default class {
return this.applicationInstance.lookup('service:router');
}

_getPlatformService() {
return this.applicationInstance.lookup('service:platform');
}

_getRootUrl() {
let router = this._getRouter();
let rootURL = router.get('rootURL');

if (this.isNativeBuild() && !Ember.testing) {
rootURL = '#' + rootURL;
}

if (rootURL.charAt(rootURL.length - 1) !== '/') {
rootURL = rootURL + '/';
}
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

module.exports = {
name: require('./package').name
name: require('./package').name,
// Uncomment when developing locally. i.e. (yarn link ember-href-to)
// isDevelopingAddon() {
// return true;
// }
};
18 changes: 12 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2653,10 +2653,15 @@ [email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1"

[email protected], component-emitter@^1.2.1:
[email protected]:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"

component-emitter@^1.2.1, component-emitter@~1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==

[email protected]:
version "0.0.3"
resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143"
Expand Down Expand Up @@ -5054,7 +5059,7 @@ [email protected], isarray@~1.0.0:
[email protected]:
version "2.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e"
integrity sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=
integrity sha512-c2cu3UxbI+b6kR3fy0nRnAhodsvR9dx7U5+znCOzdj6IfP3upFURTr0Xl5BlQZNKZjEtxrmVyfSdeE3O57smoQ==

isbinaryfile@^3.0.3:
version "3.0.3"
Expand Down Expand Up @@ -5926,6 +5931,7 @@ mout@^1.0.0:
[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==

ms@^2.1.1:
version "2.1.1"
Expand Down Expand Up @@ -7157,11 +7163,11 @@ [email protected]:
to-array "0.1.4"

socket.io-parser@~3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.0.tgz#2b52a96a509fdf31440ba40fed6094c7d4f1262f"
integrity sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==
version "3.3.3"
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.3.tgz#3a8b84823eba87f3f7624e64a8aaab6d6318a72f"
integrity sha512-qOg87q1PMWWTeO01768Yh9ogn7chB9zkKtQnya41Y355S0UmpXgpcrFwAgjYJxu9BdKug5r5e9YtVSeWhKBUZg==
dependencies:
component-emitter "1.2.1"
component-emitter "~1.3.0"
debug "~3.1.0"
isarray "2.0.1"

Expand Down